Example #1
0
 public void removeChild(String name) {
   TreeNode child = getChild(name);
   if (child != null) {
     child.parent = null;
     children.remove(name);
   }
 }
Example #2
0
 public TreeNode getChild(String path[]) {
   TreeNode node = this;
   for (int i = 0; i < path.length; i++) {
     node = node.getChild(path[i]);
     if (node == null) {
       return null;
     }
   }
   return node;
 }
Example #3
0
 public TreeNode getOrCreateChild(String path[]) {
   TreeNode node = this;
   TreeNode child = null;
   for (int i = 0; i < path.length; i++) {
     child = node.getChild(path[i]);
     if (child == null) {
       child = new TreeNode(node, path[i]);
       node.addChild(child);
     }
     node = child;
   }
   return node;
 }
Example #4
0
 public void addChild(TreeNode child) {
   child.parent = this;
   children.put(child.getName(), child);
 }