Examples: TextParagraph property (RichTextRange - Java™)
This agent searches for the first occurrence of a string in a text paragraph in an item.
import lotus.domino.*;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
// (Your code goes here)
DocumentCollection dc = agentContext.getUnprocessedDocuments();
Document doc = dc.getFirstDocument();
RichTextItem body = (RichTextItem)doc.getFirstItem("Body");
RichTextNavigator rtnav = body.createNavigator();
RichTextRange rtrange = body.createRange();
if (rtnav.findFirstElement(
RichTextItem.RTELEM_TYPE_TEXTPARAGRAPH)) {
String searchString = "foo";
boolean foundit = false;
do {
rtrange.setBegin(rtnav);
String para = rtrange.getTextParagraph();
if (para.toLowerCase().indexOf(searchString) >= 0) {
foundit = true;
break;
}
} while (rtnav.findNextElement());
if (foundit)
System.out.println(
"Body contains \"" + searchString + "\"");
else
System.out.println(
"Body does not contain \"" + searchString + "\"");
}
else
System.out.println("Body does not contain any text");
} catch(Exception e) {
e.printStackTrace();
}
}
}