次のエージェントは、さまざまなデータ型のアイテムを持つ文書を作成します。
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();
// Create text item with implied data type
doc.replaceItemValue("Subject", "Creating items ...");
// Create text item explicitly specifying data type
Item textItem = doc.replaceItemValue("textItem", null);
textItem.setValueString("South America");
textItem.setSummary(true);
// Create numeric item explicitly specifying data type
Item numberItem = doc.replaceItemValue("numberItem",
null);
numberItem.setValueDouble(98);
numberItem.setSummary(true);
// Create date-time item explicitly specifying data type
Item dateTimeItem = doc.replaceItemValue("dateTimeItem",
null);
DateTime dt = session.createDateTime("Today");
dt.setNow();
dateTimeItem.setDateTimeValue(dt);
dateTimeItem.setSummary(true);
// Create multi-value text item explicitly specifying
//data type
Vector v = new Vector();
v.addElement("Bicycle");
v.addElement("Train");
v.addElement("Foot");
Item textListItem = doc.replaceItemValue("textListItem",
null);
textListItem.setValues(v);
textListItem.setSummary(true);
// Create authors item explicitly specifying data type
Vector v2 = new Vector();
v2.addElement("Mariko Nakamura");
v2.addElement("Pierre Singer");
Item authorsItem = doc.replaceItemValue("authorsItem",
null);
authorsItem.setValues(v2);
authorsItem.setSummary(true);
authorsItem.setAuthors(true);
// Save the document
doc.save(true, true);
} catch(Exception e) {
e.printStackTrace();
}
}
}