例: HasChildren property

次のエージェントは、アウトライン内のエントリをすべて取得します。子エントリは、再帰関数を使用してレベルを下げて区別します。

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();
    }
  }
}