Example #1
0
 /** 插入子节点 */
 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;
 }
Example #2
0
 /**
  * 得到节点全路径
  *
  * @return
  */
 public String getFullPath(String separator) {
   if (parent == null) {
     return separator + key;
   }
   String str = parent.getFullPath(separator);
   return str + separator + key;
 }
Example #3
0
 private void setPath(List<String> paths) {
   if (parent != null) {
     parent.setPath(paths);
   } else {
     paths.add("/");
   }
   paths.add(String.valueOf(key));
 }