例: TextParagraph property (RichTextRange - Java™)

次のエージェントは、アイテム内のテキスト段落で最初の文字列を検索します。

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();
    }
  }
}