protected void removeChild(String segment) { if (children != null) { PrefetchTreeNode child = getChild(segment); if (child != null) { children.remove(child); child.parent = null; } } }
void merge(PrefetchTreeNode original, PrefetchTreeNode toMerge) { if (toMerge.getSemantics() != UNDEFINED_SEMANTICS) { original.setSemantics(toMerge.getSemantics()); } if (!toMerge.isPhantom()) { original.setPhantom(false); } for (PrefetchTreeNode childToMerge : toMerge.getChildren()) { PrefetchTreeNode childOrigin = original.getChild(childToMerge.getName()); if (childOrigin == null) { childOrigin = original.addPath(childToMerge.getName()); } merge(childOrigin, childToMerge); } }
protected void removeChild(String segment) { if (children != null) { PrefetchTreeNode child = getChild(segment); if (child != null) { children.remove(child); child.parent = null; } } }
/** * Looks up an existing node in the tree desribed by the dot-separated path. Will * return null if no matching child exists. */ public PrefetchTreeNode getNode(String path) { if (Util.isEmptyString(path)) { throw new IllegalArgumentException("Empty path: " + path); } PrefetchTreeNode node = this; StringTokenizer toks = new StringTokenizer(path, Entity.PATH_SEPARATOR); while (toks.hasMoreTokens() && node != null) { String segment = toks.nextToken(); node = node.getChild(segment); } return node; }
/** * Looks up an existing node in the tree desribed by the dot-separated path. * Will return null if no matching child exists. */ public PrefetchTreeNode getNode(String path) { if (Util.isEmptyString(path)) { throw new IllegalArgumentException("Empty path: " + path); } PrefetchTreeNode node = this; StringTokenizer toks = new StringTokenizer(path, Entity.PATH_SEPARATOR); while (toks.hasMoreTokens() && node != null) { String segment = toks.nextToken(); node = node.getChild(segment); } return node; }
/** * Adds a "path" with specified semantics to this prefetch node. All yet * non-existent nodes in the created path will be marked as phantom. * * @return the last segment in the created path. */ public PrefetchTreeNode addPath(String path) { if (Util.isEmptyString(path)) { throw new IllegalArgumentException("Empty path: " + path); } PrefetchTreeNode node = this; StringTokenizer toks = new StringTokenizer(path, Entity.PATH_SEPARATOR); while (toks.hasMoreTokens()) { String segment = toks.nextToken(); PrefetchTreeNode child = node.getChild(segment); if (child == null) { child = new PrefetchTreeNode(node, segment); node.addChild(child); } node = child; } return node; }
/** * Adds a "path" with specified semantics to this prefetch node. All yet non-existent * nodes in the created path will be marked as phantom. * * @return the last segment in the created path. */ public PrefetchTreeNode addPath(String path) { if (Util.isEmptyString(path)) { throw new IllegalArgumentException("Empty path: " + path); } PrefetchTreeNode node = this; StringTokenizer toks = new StringTokenizer(path, Entity.PATH_SEPARATOR); while (toks.hasMoreTokens()) { String segment = toks.nextToken(); PrefetchTreeNode child = node.getChild(segment); if (child == null) { child = new PrefetchTreeNode(node, segment); node.addChild(child); } node = child; } return node; }