On 6.11.12 18:12, ang...@apache.org wrote:
+    @Nonnull
+    public NodeUtil getOrAddTree(String relativePath, String primaryTypeName) {
+        if (relativePath.indexOf('/') == -1) {
+            return getOrAddChild(relativePath, primaryTypeName);
+        } else {
+            TreeLocation location = 
LocationUtil.getTreeLocation(tree.getLocation(), relativePath);
+            if (location.getTree() == null) {
+                NodeUtil target = this;
+                for (String segment : Text.explode(relativePath, '/')) {
+                    if (PathUtils.denotesCurrent(segment)) {
+                        continue;
+                    } else if (PathUtils.denotesParent(segment)) {
+                        target = target.getParent();
+                    } else if (target.hasChild(segment)) {
+                        target = target.getChild(segment);
+                    } else {
+                        target = target.addChild(segment, primaryTypeName);
+                    }
+                }
+                return target;
+            } else {
+                return new NodeUtil(location.getTree());
+            }
+        }
+    }

rootNode.getOrAddTree("a/b/../../c/d/../../e/f", "");

adds the three sub trees /a/b, /c/d and /e/f. Is this really the intended behaviour?

Michael

Reply via email to