JAVA/CORBA CLASSES
Examples: DateTimeValue, ValueDouble, ValueInteger, Values, and ValueString properties
1. This agent gets item values of various types.
import lotus.domino.*;
import java.util.*;
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();
if (doc != null) {
// Text item
Item item = doc.getFirstItem("textItem");
System.out.println(item.getName());
System.out.println(item.getValueString());
// Numeric item
item = doc.getFirstItem("numberItem");
System.out.println("\n" + item.getName());
System.out.println("Integer value: " +
item.getValueInteger());
System.out.println("Double value: " +
item.getValueDouble());
// Date-time item
item = doc.getFirstItem("dateTimeItem");
System.out.println("\n" + item.getName());
System.out.println(
item.getDateTimeValue().getLocalTime());
// Multi-value text item
item = doc.getFirstItem("textListItem");
System.out.println("\n" + item.getName());
Enumeration values = item.getValues().elements();
while (values.hasMoreElements()) {
System.out.println((String)values.nextElement());
}
}
} catch(Exception e) {
e.printStackTrace();
}
}
}
2. This agent increments a numeric item and adds a value to a multi-value text item.
import lotus.domino.*;
import java.util.*;
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();
if (doc != null) {
// Numeric item
Item item = doc.getFirstItem("numberItem");
System.out.println(item.getName());
System.out.println("Old value: " +
item.getValueInteger());
item.setValueInteger(item.getValueInteger() + 1);
System.out.println("New value: " +
item.getValueInteger());
// Multi-value text item
item = doc.getFirstItem("textListItem");
Vector v = item.getValues();
v.addElement("New value");
item.setValues(v);
System.out.println("\n" + item.getName());
Enumeration values = item.getValues().elements();
while (values.hasMoreElements()) {
System.out.println((String)values.nextElement());
}
doc.save(true, true);
}
} catch(Exception e) {
e.printStackTrace();
}
}
}
See Also
DateTimeValue property
ValueDouble property
ValueInteger property
Values property
ValueString property
Glossary
Feedback on
Help
or
Product Usability
?
Help on Help
All Help Contents
Glossary