JAVA/CORBA クラス


例:getParentDocument メソッドと getPrevSibling メソッド
次のエージェントは、現在のデータベースの [By Category] ビューの最後の文書の親文書を検索し、その直接の返答文書の数をカウントします。

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();
     View view = db.getView("By Category");
     Document tmpdoc;
     Document doc = view.getLastDocument();
     if (doc.isResponse()) {
       Document parent = view.getParentDocument(doc);
       System.out.print
       ("Last document in \"By Category\" is \"" +
       parent.getItemValueString("Subject") + "\"");
       int count = 1;
       doc = view.getPrevSibling(doc);
       while (doc != null) {
         count++;
         tmpdoc = view.getPrevSibling(doc);
         doc.recycle();
         doc = tmpdoc;
       }
       System.out.println
       (" with " + count + " responses"); }
     else
       System.out.println
       ("Last document in \"By Category\" is \"" +
       doc.getItemValueString("Subject") + "\"");
   } catch(Exception e) {
     e.printStackTrace();
   }
 }
}

関連項目