例: appendItemValue method

次のエージェントは、文字列、複数値の文字列、数値 (int 型)、数値 (double 型)、複数値の数値 (Integer 型の値のベクトル)、日付/時刻の各アイテムを作成します。

import lotus.domino.*;
import java.util.Vector;
public class JavaAgent extends AgentBase {
  public void NotesMain() {
    try {
      Session session = getSession();
      AgentContext agentContext = session.getAgentContext();
      // (Your code goes here) 
      Database db = agentContext.getCurrentDatabase();
      Document doc = db.createDocument();
      doc.appendItemValue("Form", "Main Topic");
      // Create text item with one String value
      doc.appendItemValue("Subject", 
                  "Test appendItemValue");
      // Create text item with multiple String values
      Vector stringMultiple = new Vector();
      stringMultiple.addElement("String one");
      stringMultiple.addElement("String two");
      stringMultiple.addElement("String three");
      doc.appendItemValue("stringMultiple", 
                    stringMultiple);
      // Create numeric item with one int value
      doc.appendItemValue("integer", 101);
      // Create numeric item with one double value
      doc.appendItemValue("double", 1.01);
      // Create numeric item with multiple Integer values
      Vector integerMultiple = new Vector();
      Integer one = new Integer(1);
      integerMultiple.addElement(one);
      Integer two = new Integer(2);
      integerMultiple.addElement(two);
      Integer three = new Integer(3);
      integerMultiple.addElement(three);
      doc.appendItemValue("integerMultiple", 
                    integerMultiple);
      // Create time item with one DateTime value
      DateTime timenow = session.createDateTime("Today");
      timenow.setNow();
      doc.appendItemValue("dateTime", timenow);
      
      if (doc.save())
        System.out.println("Document created and saved");
      else
        System.out.println("Something went wrong");
    } catch(Exception e) {
      e.printStackTrace();
    }
  }
}