例: Authors and IsResponse properties

次のエージェントは、現在のユーザーが作成者になっている返答文書の数をカウントします。

import lotus.domino.*;
import java.util.Vector;
public class JavaAgent extends AgentBase {
  public void NotesMain() {
    try {
      Session session = getSession();
      AgentContext agentContext = 
          session.getAgentContext();
      // (Your code goes here) 
      Database db = session.getDatabase(
                "FrenchFry", "notesua¥¥progwork");
      DocumentCollection dc = db.getAllDocuments();
      Vector authors;
      int count = 0;
      Document doc = dc.getFirstDocument();
      while (doc != null) {
        if (!doc.isResponse()) {
          authors = doc.getAuthors();
          if (authors.contains(session.getUserName()))
            count++; }
        doc = dc.getNextDocument(doc); }
      System.out.println(session.getUserName() + 
                " is author on " +
      count + " main documents");
    } catch(Exception e) {
      e.printStackTrace();
    }
  }
}