JAVA/CORBA CLASSES


Examples: compact method
This agent compacts the Body item of the current or first selected document after a search and replace.

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 rti = (RichTextItem)doc.getFirstItem("Body");
     RichTextNavigator rtnav = rti.createNavigator();
     if (rtnav.findFirstElement(RichTextItem.RTELEM_TYPE_TEXTPARAGRAPH)) {
       RichTextRange rtrange = rti.createRange();
       int n = 0;
       while (rtrange.findandReplace("foo", "bar") > 0) {
         n++;
         rti.update(); // Must update before looping
       }

       if (n > 0)
         rti.compact();
       doc.save(true, true);
     }

   } catch(NotesException e) {
     System.out.println(e.id + e.text);
     e.printStackTrace();
   }
 }
}

See Also