Examples: Locating a document by ID in Java classes

This agent demonstrates getting documents whose IDs are stored in a vector.

import lotus.domino.*;
import java.util.Vector;
import java.util.Enumeration;
public class JavaAgent extends AgentBase {  
  Vector v;
  public void NotesMain() {
    try {
      Session session = getSession();
      AgentContext agentContext = 
           session.getAgentContext();
      // (Your code goes here)       
      Database db = agentContext.getCurrentDatabase();
      saveIDs(db);
      Enumeration e = v.elements();
      while (e.hasMoreElements()) {
        String id = (String)e.nextElement();
        Document doc = db.getDocumentByID(id);
        System.out.println(
            doc.getItemValueString("Subject"));
        }
    } catch(Exception e) {
      e.printStackTrace();
    }
  }
  
  public void saveIDs(Database db) {
    try {
      DocumentCollection dc = db.getAllDocuments();
      v = new Vector();
      Document doc = dc.getFirstDocument();
      while (doc != null) {
        v.addElement(doc.getNoteID());
        doc = dc.getNextDocument(); }
    } catch(Exception e) {
      e.printStackTrace();
    }
  }
}