Example #1
0
      MyNode findNode(String fqn) {
        MyNode curr, n;
        StringTokenizer tok;
        String child_name;

        if (fqn == null) return null;
        curr = this;
        tok = new StringTokenizer(fqn, ReplicatedTreeView.SEP);

        while (tok.hasMoreTokens()) {
          child_name = tok.nextToken();
          n = curr.findChild(child_name);
          if (n == null) return null;
          curr = n;
        }
        return curr;
      }
Example #2
0
      /**
       * Adds a new node to the view. Intermediary nodes will be created if they don't yet exist.
       * Returns the first node that was created or null if node already existed
       */
      public MyNode add(String fqn) {
        MyNode curr, n, ret = null;
        StringTokenizer tok;
        String child_name;

        if (fqn == null) return null;
        curr = this;
        tok = new StringTokenizer(fqn, ReplicatedTreeView.SEP);

        while (tok.hasMoreTokens()) {
          child_name = tok.nextToken();
          n = curr.findChild(child_name);
          if (n == null) {
            n = new MyNode(child_name);
            if (ret == null) ret = n;
            curr.add(n);
          }
          curr = n;
        }
        return ret;
      }