Examples: findNextString method

This agent finds the next search string in the Body item of the current or first selected document.

import lotus.domino.*;

public class JavaAgent extends AgentBase {

  public void NotesMain() {

    try {
      Session session = getSession();
      AgentContext agentContext = session.getAgentContext();

      // (Your code goes here) 
      String searchString = "foo";
      DocumentCollection dc = agentContext.getUnprocessedDocuments();
      Document doc = dc.getFirstDocument();
      RichTextItem body = (RichTextItem)doc.getFirstItem("Body");
      RichTextNavigator rtnav = body.createNavigator();
      RichTextRange rtrange = body.createRange();
      if (rtnav.findFirstString(searchString,
      RichTextItem.RT_FIND_CASEINSENSITIVE)) {
        do {
          rtrange.setBegin(rtnav);
          System.out.println(rtrange.getTextParagraph());
        } while (rtnav.findNextString(searchString,
        RichTextItem.RT_FIND_CASEINSENSITIVE));
      }
      else
        System.out.println("String not found");

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