private NodeSource getRootNodeSource() { NodeSource src = this; while (!(src instanceof RootNodeSource) && src.getParent() != null) { src = src.getParent(); } return src; }
/** * DOCUMENT ME! * * @return DOCUMENT ME! */ public String getFullPath() { String result = ""; NodeSource src = this; while ((src != null) && (src.getTagName() != null)) { result = "/" + src.getTagName() + result; src = src.parent; } return result; }
private NodeSource getNodeSourceByRelativePath(String tag) { String[] tags = tag.split("/"); NodeSource select = this; for (int i = 0; i < tags.length; i++) { select = select.getChildByTagName(tags[i]); if (select == null) { return null; } } return select; }
/** * DOCUMENT ME! * * @param tag DOCUMENT ME! * @return DOCUMENT ME! */ public NodeSource getChildByTagName(String tag) { if (this.children != null) { Iterator it = this.children.iterator(); while (it.hasNext()) { NodeSource result = (NodeSource) it.next(); if (tag.equals(result.getTagName())) { return result; } } } return null; }
/** * DOCUMENT ME! * * @param tag DOCUMENT ME! * @return DOCUMENT ME! */ public NodeSource getNodeSourceByPath(String tag) { if ((tag != null) || (tag.length() == 0)) { NodeSource context = this; String prefix = null; if (tag.startsWith(prefix = "/root/") || tag.equals(prefix = "/root") || tag.startsWith(prefix = "/")) { context = this.getRootNodeSource(); tag = tag.substring(prefix.length()); } return context.getNodeSourceByRelativePath(tag); } return this; }
/** * DOCUMENT ME! * * @param tag DOCUMENT ME! * @return DOCUMENT ME! */ public NodeSource getNodeSourceByTagName(String tag) { Iterator it = this.children.iterator(); while (it.hasNext()) { NodeSource src = (NodeSource) it.next(); if (tag.equals(src.getTagName())) { return src; } else { NodeSource result = src.getNodeSourceByTagName(tag); if (result != null) { return result; } } } return null; }
/** * DOCUMENT ME! * * @param groups DOCUMENT ME! */ public void layoutGroup(String[] groups) { NodeSource parent = this.getParent(); NodeSource[] srcs = new NodeSource[groups.length]; for (int i = 0; i < srcs.length; i++) { srcs[i] = parent.getNodeSourceByTagName(groups[i]); } parent.remove(this); NodeSource src = parent; for (int i = 0; i < srcs.length; i++) { NodeSource p = srcs[i].getParent(); if (p != null) { p.remove(srcs[i]); } src.add(srcs[i]); src = srcs[i]; } }
/** * DOCUMENT ME! * * @param src DOCUMENT ME! * @return DOCUMENT ME! */ public NodeSource add(NodeSource src) { this.children.add(src); src.parent = this; return src; }