public WebTreeNode getChildNodeById(String id) { if (id == null) return null; for (WebTreeNode wtn : childs) { if (wtn.getIdName().equals(id)) return wtn; } return null; }
public WebTreeNode appendChild(WebTreeNode wtn) { wtn.removeFromParent(); wtn.parentTN = this; childs.add(wtn); return this; }
public int getLevel() { if (parentTN == null) return 0; return parentTN.getLevel() + 1; }
private void getPathIdNames(ArrayList<String> pins) { if (parentTN != null) parentTN.getPathIdNames(pins); pins.add(this.id_name); }
private void getNodePaths(ArrayList<WebTreeNode> ans) { if (parentTN != null) parentTN.getNodePaths(ans); ans.add(this); }
/** * 获得从根开始到本节点的父节点所经过的所有节点 * * @return */ public ArrayList<WebTreeNode> getAncestors() { if (parentTN == null) return null; return parentTN.getNodePath(); }
public boolean isLastInParent() { if (parentTN == null) return true; return parentTN.getLastChild() == this; }