例: gotoEntry method

次のエージェントは、全文検索を使用して Document オブジェクトを取得し、次にビュー内でそのオブジェクトに関連するエントリを取得します。

import lotus.domino.*;
public class JavaAgent extends AgentBase {
  public void NotesMain() {
    try {
      Session session = getSession();
      AgentContext agentContext = session.getAgentContext();
      // (Your code goes here) 
      Database db = agentContext.getCurrentDatabase();
      Agent agent = agentContext.getCurrentAgent();
      String searchString = agent.getComment();
      View view = db.getView("By Category");
      view.setAutoUpdate(false);
      ViewNavigator nav = view.createViewNav();
      db.updateFTIndex(true);
      int count = view.FTSearch(searchString, 0);
      if (count == 0)
        System.out.println("Nothing found");
      else {
        System.out.println(count + " found");
        Document tmpdoc;
        Document doc = view.getFirstDocument();
        ViewEntry entry = null;
        while (doc != null) {
          System.out.println(doc.getItemValueString
          ("Subject"));
          if (nav.gotoEntry(doc)) {
            entry = nav.getCurrent();
            System.out.println("Position in ¥"By Category¥
            " is " +
            entry.getPosition('.')); }
          else
            System.out.println("Not in ¥"By Category¥" view");
          tmpdoc = view.getNextDocument(doc); 
          doc.recycle();
          doc = tmpdoc;
        } 
      }
    } catch(Exception e) {
      e.printStackTrace();
    }
  }
}