例: DocUnID property

次のエージェントは、現在の文書の Body アイテム内の最初または唯一の文書リンクのリンク先文書の Subject アイテムの値を表示します。

import lotus.domino.*;

public class JavaAgent extends AgentBase {

  public void NotesMain() {

    try {
      Session session = getSession();
      AgentContext agentContext = session.getAgentContext();

      // (Your code goes here) 
      DocumentCollection dc = agentContext.getUnprocessedDocuments();
      Document doc = dc.getFirstDocument();
      RichTextItem body = (RichTextItem)doc.getFirstItem("Body");
      RichTextNavigator rtnav = body.createNavigator();
      if (rtnav.findFirstElement(RichTextItem.RTELEM_TYPE_DOCLINK)) {
        String idzero = new String("00000000000000000000000000000000");
        RichTextDoclink rtlink = (RichTextDoclink)rtnav.getElement();
        String docunid = rtlink.getDocUnID();
        if (!docunid.equals(idzero)) {
          DbDirectory dbdir = session.getDbDirectory(
            rtlink.getServerHint());
          Database db = dbdir.openDatabaseByReplicaID(
            rtlink.getDBReplicaID());
          if (db.isOpen()) {
            try {
              Document doc2 = db.getDocumentByUNID(
                rtlink.getDocUnID());
              System.out.println(doc2.getItemValueString("Subject"));
            } catch(NotesException ne) {
              System.out.println("Could not open document");
           }
          }
          else
            System.out.println("No local replica");
        }
        else
          System.out.println("Link does not have doc component");
      }
      else
        System.out.println("No doclinks in Body");

    } catch(Exception e) {
      e.printStackTrace();
    }
  }
}