次のエージェントは、最初の文書コレクションから 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 there before deleting
if (dc1.getDocument(doc) != null)
dc1.deleteDocument(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();
}
}
}