次のエージェントは、すべてのテキスト段落内のすべてのテキストランを取得します。
import lotus.domino.*;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
// (Your code goes here)
DocumentCollection dc = agentContext.getUnprocessedDocuments();
Document doc = dc.getFirstDocument();
RichTextItem body = (RichTextItem)doc.getFirstItem("Body");
RichTextNavigator rtnav = body.createNavigator();
RichTextRange rtrange = body.createRange();
RichTextRange rtrange2 = body.createRange();
if (rtnav.findFirstElement(
RichTextItem.RTELEM_TYPE_TEXTPARAGRAPH)) {
int paraCount = 0;
do {
paraCount++;
int runCount = 0;
rtrange.setBegin(rtnav);
rtrange.setEnd(rtnav);
RichTextNavigator rtnav2 = rtrange.getNavigator();
rtnav2.findFirstElement(
RichTextItem.RTELEM_TYPE_TEXTRUN);
do {
runCount++;
rtrange2.setBegin(rtnav2);
rtrange2.setEnd(rtnav2);
System.out.println(
"Para " + paraCount + ", run " + runCount);
System.out.println(
"¥t" + rtrange2.getTextRun());
} while (rtnav2.findNextElement());
} while (rtnav.findNextElement());
}
else
System.out.println("Body does not contain any text");
} catch(Exception e) {
e.printStackTrace();
}
}
}