public void removeChild(String name) { TreeNode child = getChild(name); if (child != null) { child.parent = null; children.remove(name); } }
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; }
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; }
public void addChild(TreeNode child) { child.parent = this; children.put(child.getName(), child); }