例: clone method (RichTextRange - Java™)

次のエージェントは、作成された範囲における現在の文書の Body アイテムの最初の段落を取得した後、複製された範囲の 2 番目の段落を取得します。

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)) {
        rtrange.setBegin(rtnav);
        if (rtnav.findNextElement(
        RichTextItem.RTELEM_TYPE_TEXTPARAGRAPH)) {
          RichTextRange rtrange2 = rtrange.Clone();
          rtrange2.setBegin(rtnav);
          // Print first 2 paragraphs
          System.out.println(rtrange.getTextParagraph());
          System.out.println(rtrange2.getTextParagraph());
        }
        else
          System.out.println("Body does not have a second paragraph");
      }
      else
        System.out.println("Body does not contain any text");

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