例: getChild, getNextSibling, and getParent methods

  1. 次のエージェントは、階層内の異なるレベルにあるエントリを表す異なる変数を使用して、階層内の 3 レベル下位までのビューエントリを取得します。
    import lotus.domino.*;
    public class JavaAgent extends AgentBase {
      
      String getEntryType(ViewEntry entry) {
        String t = null;
        try {
          if (entry.isCategory()) t = "category";
          else if (entry.isDocument()) t = "document";
          else if (entry.isTotal()) t = "total"; }
        catch (Exception e) {
          e.printStackTrace(); }
        return t; }
      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");
          view.setAutoUpdate(false);
          ViewNavigator nav = view.createViewNav();
          int n = 0;
          String tabs = null;
          ViewEntry tmpentry;
          ViewEntry entry = nav.getFirst();
          while (entry != null) {
            n++;
            System.out.println
            ("Entry #" + n + " is a " + getEntryType(entry));
            ViewEntry tmpentry2;
            ViewEntry entry2 = nav.getChild(entry);
            while (entry2 != null) {
              n++;
              System.out.println
              ("¥tEntry #" + n + " is a " + 
              getEntryType(entry2));
              ViewEntry tmpentry3;
              ViewEntry entry3 = nav.getChild(entry2);
              while (entry3 != null) {
                n++;
                System.out.println
                ("¥t¥tEntry #" + n + " is a " + 
                getEntryType(entry3));
                tmpentry3 = nav.getNextSibling(entry3); 
                entry3.recycle();
                entry3 = tmpentry3; }
              tmpentry2 = nav.getNextSibling(entry2);
              entry2.recycle();
              entry2 = tmpentry2; }
            tmpentry = nav.getNextSibling(entry);
            entry.recycle();
            entry = tmpentry; }
        } catch(Exception e) {
          e.printStackTrace();
        }
      }
    }
  2. 次のエージェントは、階層内の異なるレベルにあるエントリを表す 1 つの変数を使用して、階層内の 3 レベル下位までのビューエントリを取得します。
    import lotus.domino.*;
    public class JavaAgent extends AgentBase {
      
      String getEntryType(ViewEntry entry) {
        String t = null;
        try {
          if (entry.isCategory()) t = "category";
          else if (entry.isDocument()) t = "document";
          else if (entry.isTotal()) t = "total"; }
        catch (Exception e) {
          e.printStackTrace(); }
        return t; }
      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");
          view.setAutoUpdate(false);
          ViewNavigator nav = view.createViewNav();
          int n = 0;
          ViewEntry entry = nav.getFirst();
          while (entry != null) {
            n++;
            System.out.println
            ("Entry #" + n + " is a " + getEntryType(entry));
            entry = nav.getChild();
            if (entry != null) {
              while (entry != null) {
                n++;
                System.out.println
                ("¥tEntry #" + n + " is a " + 
                getEntryType(entry));
                entry = nav.getChild();
                if (entry != null) {
                  while (entry != null) {
                    n++;
                    System.out.println
                    ("¥t¥tEntry #" + n + " is a " + 
                    getEntryType(entry));
                    entry = nav.getNextSibling(); }
                  entry = nav.getParent(); }
                entry = nav.getNextSibling(); }
              entry = nav.getParent(); }
            entry = nav.getNextSibling(); }
        } catch(Exception e) {
          e.printStackTrace();
        }
      }
    }