例: remove method (RichTextRange - Java™)

次のエージェントは、現在の文書の最初の表にあるすべてのセルの内容を削除します。

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();
      if (rtnav.findFirstElement(RichTextItem.RTELEM_TYPE_TABLE)) {
        // Set up range and navigator for table
        RichTextRange rtrange = body.createRange();
        rtrange.setBegin(rtnav);
        rtrange.setEnd(rtnav);
        RichTextNavigator rtnav2 = rtrange.getNavigator();
        // Find cells in table
        RichTextRange rtrange2 = body.createRange();
        rtnav2.findFirstElement(RichTextItem.RTELEM_TYPE_TABLECELL);
        do {
          rtrange2.setBegin(rtnav2);
          rtrange2.setEnd(rtnav2);
          rtrange2.remove();
        } while (rtnav2.findNextElement());
        doc.save(true, true);
      }
      else
        System.out.println("Body does not contain any tables");

    } catch(Exception e) {
      e.printStackTrace();
    }
  }
}