例: getItemValue method, getItemValueDouble, getItemValueInteger, and getItemValueString

次のエージェントは、文字列、リッチテキスト、整数、倍精度数値、複数値を持つ文字列、複数値を持つ数値、日付/時刻のそれぞれのアイテムの値を取得します。

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.getAllDocuments();
      Document doc = dc.getFirstDocument();
      while (doc != null) {
        // Get text item with one value
        System.out.println("[ " + 
              doc.getItemValueString("Subject") + " ]");
        // Get rich text item rendered to plain text
        System.out.println(doc.getItemValueString("Body"));
        // Get numeric item with one integer value
        System.out.println(doc.getItemValueInteger("integer"));
        // Get numeric item with one decimal value
        System.out.println(doc.getItemValueDouble("double"));
        // Get text item with multiple values
        Vector sM = doc.getItemValue("stringMultiple");
        for (int i=0; i<sM.size(); i++)
          System.out.println((i+1) + ": " + sM.elementAt(i));
        // Get numeric item with multiple integer values
        // - must convert from double
        Vector iM = doc.getItemValue("integerMultiple");
        Double d;
        for (int i=0; i<iM.size(); i++) {
          d = (Double)iM.elementAt(i);
          System.out.println((i+1) + ": " + d.intValue()); }
        // Get date-time item
        Vector dM = doc.getItemValue("dateTime");
        if (dM.size() > 0) {
          DateTime dt = (DateTime)dM.elementAt(0);
          System.out.println(dt.getLocalTime()); }
        
        doc = dc.getNextDocument(); }
    } catch(Exception e) {
      e.printStackTrace();
    }
  }
}