Examples: setEnd method
This agents gets a requested range of paragraphs from the Body item of the current document. The code uses setBegin to mark the first paragraph in the range, and setPositionAtEnd followed by setEnd to mark and include the last paragraph in the range.
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();
if (rtnav.findFirstElement(
RichTextItem.RTELEM_TYPE_TEXTPARAGRAPH)) {
RichTextRange rtrange = body.createRange();
rtrange.setBegin(rtnav);
if (rtnav.findNthElement(
RichTextItem.RTELEM_TYPE_TEXTPARAGRAPH, 2)) {
rtnav.setPositionAtEnd(rtnav);
rtrange.setEnd(rtnav);
RichTextNavigator rtnav2 = rtrange.getNavigator();
RichTextRange rtrange2 = body.createRange();
rtnav2.findFirstElement(
RichTextItem.RTELEM_TYPE_TEXTPARAGRAPH);
do {
rtrange2.setBegin(rtnav2);
System.out.println(rtrange2.getTextParagraph());
} while (rtnav2.findNextElement());
}
else
System.out.println("Body does not have 2nd paragraph");
}
else
System.out.println("No text in Body");
} catch(Exception e) {
e.printStackTrace();
}
}
}