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