例: gotoLast method

  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;
          if (nav.gotoLast()) {
            do {
              ViewEntry entry = nav.getCurrent();
              if (entry.isCategory()) t = "category";
              else if (entry.isDocument()) t = "document";
              else if (entry.isTotal()) t = "total";
              System.out.println("Last entry minus " + n +  
              "is a " + t);
              n++; }
            while (nav.gotoPrev()); }
        } 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 = null;
          if (nav.gotoLast()) {
            if (nav.gotoPrev()) {
              entry = nav.getCurrent();
              String t = null;
              if (entry.isCategory()) t = "category";
              else if (entry.isDocument()) t = "document";
              else if (entry.isTotal()) t = "total";
              else t = "Unknown";
              System.out.println("Next to the last entry is a " + t); } }
        } catch(Exception e) {
          e.printStackTrace();
        }
      }
    }