Examples: clone method (RichTextNavigator - Java)

This agent gets the first two paragraphs in the Body item of the current document. The agent finds the first paragraph with one navigator, clones it, and finds the second paragraph with the cloned navigator.

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");
      // Set navigator to first paragraph in Body item
      RichTextNavigator rtnav1 = body.createNavigator();
      if (rtnav1.findFirstElement(RichTextItem.RTELEM_TYPE_TEXTPARAGRAPH)) {
        // Set cloned navigator to second paragraph in Body item
        RichTextNavigator rtnav2 = rtnav1.Clone();
        if (rtnav2.findNextElement()) {
          RichTextRange rtrange = body.createRange();
          rtrange.setBegin(rtnav1);
          System.out.println(rtrange.getTextParagraph());
          rtrange.setBegin(rtnav2);
          System.out.println(rtrange.getTextParagraph());
        }
        else
          System.out.println("No 2nd para in Body item");
      }
      else
        System.out.println("No text in Body item");

    } catch(Exception e) {
      e.printStackTrace();
    }
  }
}