例: UniversalID property (Document - Java™)

次のエージェントは、エージェントのコメントから新規文書の Universal ID を作成します。

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();
      Agent agent = agentContext.getCurrentAgent();
      String topicID = agent.getComment();
      if (topicID != null && topicID.length() == 8) {
        Document doc = db.createDocument();
        doc.appendItemValue("Form", "Main Topic");
        doc.appendItemValue("Subject", "Topic # " + topicID);
        doc.appendItemValue("Categories", "Numbered topics");
        doc.setUniversalID("AAAABBBBCCCCDDDDEEEEFFFF" + topicID);
        doc.save();
        System.out.println("Universal ID for new topic is " +
        doc.getUniversalID());
        }
      else
        System.out.println("TopicID must be 8 characters");

    } catch(NotesException e) {
      if (e.id == NotesError.NOTES_MIN_ERROR_CODE)
        System.out.println("TopicID is not unique");
      else
        System.out.println(e.id + " " + e.text);
    } catch(Exception e) {
      e.printStackTrace();
    }
  }
}