次のエージェントは、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();
if (db.isFTIndexed()) db.updateFTIndex(false);
else db.updateFTIndex(true);
DocumentCollection dc1 = db.getAllDocuments();
DocumentCollection dc2 = db.getAllDocuments();
dc2.FTSearch("blue");
String izz = "";
Document tmpdoc;
Document doc = dc1.getFirstDocument();
while (doc != null) {
// Make sure dc2 is not empty before doing getDocument
if (dc2.getCount() != 0 && dc2.getDocument(doc)
!= null)
izz = " is blue";
else izz = " is not blue";
System.out.println
(doc.getItemValueString("Subject") + izz);
tmpdoc = dc1.getNextDocument();
doc.recycle();
doc = tmpdoc;
}
} catch(NotesException e) {
System.out.println(e.id + " " + e.text);
e.printStackTrace();
}
}
}