Example: Working with sections in Java classes

This agent displays properties for all the sections in the Body item of the current document.

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_SECTION)) {
        do {
          RichTextSection rtsection = (RichTextSection)rtnav.getElement();
          System.out.println(
            "Title = " + rtsection.getTitle());
          System.out.println("\tBar color = " + 
            rtsection.getBarColor().getNotesColor());
          System.out.println(
            "\tIs expanded = " + rtsection.isExpanded());
          System.out.println(
            "\tTitle style font = " + rtsection.getTitleStyle().getFont());
        } while (rtnav.findNextElement()); 
      }
      else
        System.out.println("No sections in Body");

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