/** 插入子节点 */ public boolean insertChild(TreeNode node) { if (children.containsKey(node.key)) { return false; } node.level = this.level + 1; node.parent = this; this.children.put(node.key, node); return true; }
/** * 得到节点全路径 * * @return */ public String getFullPath(String separator) { if (parent == null) { return separator + key; } String str = parent.getFullPath(separator); return str + separator + key; }
private void setPath(List<String> paths) { if (parent != null) { parent.setPath(paths); } else { paths.add("/"); } paths.add(String.valueOf(key)); }