例: EmbeddedObject class and ClassName, FileSize, Name, Object, Parent, Source, Type, and Verbs properties

次のエージェントは、すべての Body アイテム内の埋め込みオブジェクトすべてのプロパティを取得します。

import lotus.domino.*;
import java.util.Vector;
import java.util.Enumeration;
public class JavaAgent extends AgentBase {
  public void NotesMain() {
    try {
      Session session = getSession();
      AgentContext agentContext = session.getAgentContext();
      // (Your code goes here) 
      Database db = agentContext.getCurrentDatabase();
      DocumentCollection dc = db.getAllDocuments();
      Document doc = dc.getFirstDocument();
      while (doc != null) {
        RichTextItem body = 
        (RichTextItem)
        doc.getFirstItem("Body");
        System.out.println(doc.getItemValueString("Subject"));
        Vector v = body.getEmbeddedObjects();
        Enumeration e = v.elements();
        while (e.hasMoreElements()) {
          EmbeddedObject eo = (EmbeddedObject)e.nextElement();
          System.out.println("¥t" + eo.getName());
          String type = null;
          switch (eo.getType()) {
            case EmbeddedObject.EMBED_ATTACHMENT :
              type = "file attachment"; break;
            case EmbeddedObject.EMBED_OBJECT :
              type = "embedded object"; break;
            case EmbeddedObject.EMBED_OBJECTLINK :
              type = "object link";
            }
          System.out.println("¥t¥tType: " + type);
          if (type.equals("embedded object"))
            System.out.println("¥t¥tVerbs: " + eo.getVerbs());
          System.out.println("¥t¥tSource: " + eo.getSource());
          if (!type.equals("file attachment"))
            System.out.println("¥t¥tClass name: " +
            eo.getClassName());
          if (type.equals("file attachment"))
            System.out.println("¥t¥tSize: " + eo.getFileSize() +
            " bytes");
          System.out.println("¥t¥tParent doc: " +        
          eo.getParent().getParent().getItemValueString(
          "Subject"));
          }
        doc = dc.getNextDocument();
        }
    } catch(NotesException e) {
      System.out.println(e.id + " " + e.text);
      e.printStackTrace();
    }
  }
}