例: getFirst and getNext methods

  1. 次のエージェントは、ビューにあるすべてのエントリを最初から最後の順に取得します。

    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();
          View view = db.getView("By Category");
          view.setAutoUpdate(false);
          ViewNavigator nav = view.createViewNav();
          int n = 0;
          String t = null;
          ViewEntry tmpentry;
          ViewEntry entry = nav.getFirst();
          while (entry != null) {
            n++;
            if (entry.isCategory()) t = "category";
            else if (entry.isDocument()) t = "document";
            else if (entry.isTotal()) t = "total";
            System.out.println("Entry #" + n + " is a " + t);
            tmpentry = nav.getNext();
            entry.recycle();
            entry = tmpentry;
          }
        } catch(Exception e) {
          e.printStackTrace();
        }
      }
    }
  2. 次のエントリは、ビューの 2 番目のエントリを取得します。
    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();
          View view = db.getView("By Category");
          view.setAutoUpdate(false);
          ViewNavigator nav = view.createViewNav();
          ViewEntry entry = nav.getNext(nav.getFirst());
          if (entry != null) {
            String t = null;
            if (entry.isCategory()) t = "category";
            else if (entry.isDocument()) t = "document";
            else if (entry.isTotal()) t = "total";
            System.out.println("Entry # 2 is a " + t); }
        } catch(Exception e) {
          e.printStackTrace();
        }
      }
    }