Examples: HasChildren property

This agent gets all the entries in an outline. It separates the children by dropping levels through a recursive function.

import lotus.domino.*;
public class JavaAgent extends AgentBase {
  public void NotesMain() {
    try {
      Session session = getSession();
      AgentContext agentContext = session.getAgentContext();
      // (Your code goes here) 
      Database db = agentContext.getCurrentDatabase();
      Outline outline = db.getOutline("DiscOutline");
      System.out.println("*** " + outline.getName() + " ***");
      OutlineEntry tmpentry;
      OutlineEntry entry = outline.getFirst();
      while (entry != null) {
        System.out.println(entry.getLabel());
        if (entry.hasChildren()) printChild(outline, entry);
        tmpentry = outline.getNextSibling(entry);
        entry.recycle();
        entry = tmpentry;
        }
    } catch(Exception e) {
      e.printStackTrace();
    }
  }
  void printChild(Outline outline, OutlineEntry entry) {
    try {
      OutlineEntry tmpentry;
      tmpentry = outline.getNext(entry);
      entry.recycle();
      entry = tmpentry;
      String tabs = "";
      for (int i=0; i<entry.getLevel(); i++)
        tabs = tabs + "\t";
      while (entry != null) {
        System.out.println(tabs + entry.getLabel());
        if (entry.hasChildren()) printChild(outline, entry);
        tmpentry = outline.getNextSibling(entry);
        entry.recycle();
        entry = tmpentry;
        }
    } catch(Exception e) {
      e.printStackTrace();
    }
  }
}