Examples: replaceItemValue method

This agent replaces text, multi-value text, numeric integer, numeric double, multi-value numeric, and date-time item values.

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();
    }
  }
}