例: Java™ を使用してアイテムのプロパティにアクセスする

次のエージェントは、データベース内の最初の文書にあるすべてのアイテムのプロパティを取得します。

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();
      Enumeration items = doc.getItems().elements();
      while (items.hasMoreElements()) {
        System.out.println("******");
        Item item = (Item)items.nextElement();
        System.out.println("Name: " + item.getName());
        String type = "Undefined";
        switch (item.getType()) {
          case Item.ATTACHMENT :
            type = "Attachment"; break;
          case Item.EMBEDDEDOBJECT :
            type = "Embedded object"; break;
          case Item.ERRORITEM :
            type = "Error item"; break;
          case Item.NAMES :
            type = "Names"; break;
          case Item.AUTHORS :
            type = "Authors"; break;
          case Item.READERS :
            type = "Readers"; break;
          case Item.NOTELINKS :
            type = "Note links"; break;
          case Item.NOTEREFS :
            type = "Note references"; break;
          case Item.NUMBERS :
            type = "Numbers"; break;
          case Item.RICHTEXT :
            type = "Rich text"; break;
          case Item.TEXT :
            type = "Text"; break;
          case Item.SIGNATURE :
            type = "Signature"; break;
          case Item.DATETIMES :
            type = "Date-times"; break;
          case Item.UNAVAILABLE :
            type = "Unavailable"; break;
          case Item.UNKNOWN :
            type = "Unknown"; break;
          case Item.USERDATA :
            type = "User data"; break;
          case Item.USERID :
            type = "User ID"; break;
          }
        System.out.println("Type: " + type);
        if (item.isEncrypted())
          System.out.println("Is encrypted");
        if (item.isSigned())
          System.out.println("Is signed");
        if (item.isSummary())
          System.out.println("Is summary");
        if (item.isProtected())
          System.out.println("Is protected");
        System.out.println("Text:¥n" + item.getText());
        }
    } catch(Exception e) {
      e.printStackTrace();
    }
  }