Examples: getChild and getNextSibling methods

This agent gets the first document sorted by the key "Internet" and all its response documents to two levels.

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();
      View view = db.getView("By Category");
      Document doc = view.getDocumentByKey("Internet");
      System.out.println
      ("Project name: " + doc.getItemValueString("Subject"));
      Document tmpresponse;
      Document tmprtor;
      Document response = view.getChild(doc);
      Document rtor;
      while (response != null) {
        System.out.println
        ("\t" + response.getItemValueString("Subject"));
        rtor = view.getChild(response);
        while (rtor != null) {
          System.out.println
          ("\t\t" + rtor.getItemValueString("Subject"));
          tmprtor = view.getNextSibling(rtor); 
          rtor.recycle();
          rtor = tmprtor;
        }
        tmpresponse = view.getNextSibling(response); 
        response.recycle();
        response = tmpresponse;
      }
    } catch(Exception e) {
      e.printStackTrace();
    }
  }
}