Examples: getFirstEntry and getNextEntry methods (ViewEntryCollection - Java)

  1. This example gets all the entries in a view entry collection first to last.

    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);
          ViewEntryCollection vec = view.getAllEntries();
          ViewEntry tmpentry;
          ViewEntry entry = vec.getFirstEntry();
          while (entry != null) {
            System.out.println("Entry is at position " + 
            entry.getPosition('.'));
            tmpentry = vec.getNextEntry();
            entry.recycle();
            entry = tmpentry;
          }
       } catch(Exception e) {
          e.printStackTrace();
        }
      }
    }
  2. This example gets the second and next to last entries in a view entry collection.
    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);
          ViewEntryCollection vec = view.getAllEntries();
          ViewEntry entryFirst = vec.getFirstEntry();
          ViewEntry entryLast = vec.getLastEntry();
          System.out.println("Second entry is at position " +
          vec.getNextEntry(entryFirst).getPosition('.'));
          System.out.println("Next to last entry is at
          position " +
          vec.getPrevEntry(entryLast).getPosition('.'));
        } catch(Exception e) {
          e.printStackTrace();
        }
      }
    }