例: replaceItemValue method

次のエージェントは、文字列、複数値の文字列、整数、倍精度数値、複数値の数値、日付/時刻アイテムの値を置き換えます。

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();
      DocumentCollection dc = db.search("Subject = 
                        ¥"Test appendItemValue¥"");
      if (dc.getCount() == 1) {
        Document doc = dc.getFirstDocument();
        // Replace text item with one String value
        doc.replaceItemValue("Subject", 
                        "Test replaceItemValue");
        // Replace text item with multiple String values
        Vector stringMultiple = new Vector();
        stringMultiple.addElement("String four");
        stringMultiple.addElement("String five");
        stringMultiple.addElement("String six");
        doc.replaceItemValue(
                      "stringMultiple", stringMultiple);
        // Replace numeric item with one int value
        Integer intObj = new Integer(202);
        doc.replaceItemValue("integer", intObj);
        // Replace numeric item with one double value
        Double doubleObj = new Double(2.02);
        doc.replaceItemValue("double", doubleObj);
        // Create numeric item with multiple Integer values
        Vector integerMultiple = new Vector();
        Integer one = new Integer(3);
        integerMultiple.addElement(one);
        Integer two = new Integer(4);
        integerMultiple.addElement(two);
        Integer three = new Integer(5);
        integerMultiple.addElement(three);
        doc.replaceItemValue(
                    "integerMultiple", integerMultiple);
        // Replace time item with one DateTime value
        DateTime timenow = session.createDateTime("Today");
        timenow.setNow();
        doc.replaceItemValue("dateTime", timenow);
        if (doc.save())
          System.out.println("Document saved");
        else
          System.out.println("Something went wrong"); }
    } catch(Exception e) {
      e.printStackTrace();
    }
  }
}