Return-Path: X-Original-To: apmail-jackrabbit-oak-commits-archive@minotaur.apache.org Delivered-To: apmail-jackrabbit-oak-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DAB36D812 for ; Fri, 24 Aug 2012 09:57:16 +0000 (UTC) Received: (qmail 16918 invoked by uid 500); 24 Aug 2012 09:57:15 -0000 Delivered-To: apmail-jackrabbit-oak-commits-archive@jackrabbit.apache.org Received: (qmail 16870 invoked by uid 500); 24 Aug 2012 09:57:14 -0000 Mailing-List: contact oak-commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: oak-dev@jackrabbit.apache.org Delivered-To: mailing list oak-commits@jackrabbit.apache.org Received: (qmail 16837 invoked by uid 99); 24 Aug 2012 09:57:13 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 24 Aug 2012 09:57:13 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 24 Aug 2012 09:57:10 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 59F9B23888E3; Fri, 24 Aug 2012 09:56:26 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1376877 - in /jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr: NodeDelegate.java PropertyDelegate.java SessionDelegate.java Date: Fri, 24 Aug 2012 09:56:26 -0000 To: oak-commits@jackrabbit.apache.org From: mduerig@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120824095626.59F9B23888E3@eris.apache.org> Author: mduerig Date: Fri Aug 24 09:56:25 2012 New Revision: 1376877 URL: http://svn.apache.org/viewvc?rev=1376877&view=rev Log: OAK-275 Introduce TreeLocation interface cleanup, refactor Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java?rev=1376877&r1=1376876&r2=1376877&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java (original) +++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java Fri Aug 24 09:56:25 2012 @@ -53,9 +53,13 @@ public class NodeDelegate extends ItemDe private TreeLocation location; NodeDelegate(SessionDelegate sessionDelegate, Tree tree) { + this(sessionDelegate, tree.getLocation()); + } + + NodeDelegate(SessionDelegate sessionDelegate, TreeLocation location) { super(sessionDelegate); - assert tree != null; - this.location = tree.getLocation(); + assert location != null; + this.location = location; } @Override @@ -70,8 +74,10 @@ public class NodeDelegate extends ItemDe @Override public NodeDelegate getParent() throws InvalidItemStateException { - Tree parent = getTree().getParent(); - return parent == null ? null : new NodeDelegate(sessionDelegate, parent); + TreeLocation parentLocation = getLocation().getParent(); + return parentLocation.getTree() == null + ? null + : new NodeDelegate(sessionDelegate, parentLocation); } @Override @@ -153,8 +159,10 @@ public class NodeDelegate extends ItemDe */ @CheckForNull public NodeDelegate getChild(String relPath) { - Tree tree = getChildLocation(relPath).getTree(); - return tree == null ? null : new NodeDelegate(sessionDelegate, tree); + TreeLocation childLocation = getChildLocation(relPath); + return childLocation.getTree() == null + ? null + : new NodeDelegate(sessionDelegate, childLocation); } /** @@ -193,9 +201,9 @@ public class NodeDelegate extends ItemDe for (CoreValue value : order.getValues()) { String name = value.getString(); - Tree child = tree.getChild(name); - if (child != null && !name.startsWith(":")) { - ordered.put(name, new NodeDelegate(sessionDelegate, child)); + TreeLocation childLocation = tree.getLocation().getChild(name); + if (childLocation.getTree() != null && !name.startsWith(":")) { + ordered.put(name, new NodeDelegate(sessionDelegate, childLocation)); } } @@ -276,8 +284,8 @@ public class NodeDelegate extends ItemDe if (old != null && old.isArray()) { throw new ValueFormatException("Attempt to set a single value to multi-valued property."); } - PropertyState propertyState = tree.setProperty(name, value); - return new PropertyDelegate(sessionDelegate, tree, propertyState); + tree.setProperty(name, value); + return new PropertyDelegate(sessionDelegate, tree.getLocation().getChild(name)); } public void removeProperty(String name) throws InvalidItemStateException { @@ -297,8 +305,8 @@ public class NodeDelegate extends ItemDe if (old != null && ! old.isArray()) { throw new ValueFormatException("Attempt to set multiple values to single valued property."); } - PropertyState propertyState = tree.setProperty(name, value); - return new PropertyDelegate(sessionDelegate, tree, propertyState); + tree.setProperty(name, value); + return new PropertyDelegate(sessionDelegate, tree.getLocation().getChild(name)); } /** @@ -358,9 +366,9 @@ public class NodeDelegate extends ItemDe } private Iterator nodeDelegateIterator( - Iterator childNodeStates) { + Iterator children) { return Iterators.transform( - Iterators.filter(childNodeStates, new Predicate() { + Iterators.filter(children, new Predicate() { @Override public boolean apply(Tree tree) { return !tree.getName().startsWith(":"); @@ -368,8 +376,8 @@ public class NodeDelegate extends ItemDe }), new Function() { @Override - public NodeDelegate apply(Tree state) { - return new NodeDelegate(sessionDelegate, state); + public NodeDelegate apply(Tree tree) { + return new NodeDelegate(sessionDelegate, tree); } }); } @@ -386,8 +394,7 @@ public class NodeDelegate extends ItemDe new Function() { @Override public PropertyDelegate apply(PropertyState propertyState) { - return new PropertyDelegate(sessionDelegate, location.getTree(), - propertyState); + return new PropertyDelegate(sessionDelegate, location.getChild(propertyState.getName())); } }); } Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java?rev=1376877&r1=1376876&r2=1376877&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java (original) +++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java Fri Aug 24 09:56:25 2012 @@ -43,14 +43,6 @@ public class PropertyDelegate extends It /** The underlying {@link TreeLocation} of this node. */ private TreeLocation location; - PropertyDelegate(SessionDelegate sessionDelegate, Tree parent, PropertyState propertyState) { - super(sessionDelegate); - - assert parent != null; - assert propertyState != null; - this.location = parent.getLocation().getChild(propertyState.getName()); - } - PropertyDelegate(SessionDelegate sessionDelegate, TreeLocation location) { super(sessionDelegate); assert location != null; @@ -75,7 +67,7 @@ public class PropertyDelegate extends It @Override @CheckForNull public NodeDelegate getParent() throws InvalidItemStateException { - return new NodeDelegate(sessionDelegate, getParentTree()); + return new NodeDelegate(sessionDelegate, location.getParent()); } @Override Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java?rev=1376877&r1=1376876&r2=1376877&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java (original) +++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java Fri Aug 24 09:56:25 2012 @@ -172,11 +172,11 @@ public class SessionDelegate { @CheckForNull public NodeDelegate getRoot() { - Tree root = getTree("/"); - if (root == null) { + TreeLocation rootLocation = getLocation("/"); + if (rootLocation.getTree() == null) { return null; } else { - return new NodeDelegate(this, root); + return new NodeDelegate(this, rootLocation); } } @@ -188,8 +188,8 @@ public class SessionDelegate { */ @CheckForNull public NodeDelegate getNode(String path) { - Tree tree = getTree(path); - return tree == null ? null : new NodeDelegate(this, tree); + TreeLocation location = getLocation(path); + return location.getTree() == null ? null : new NodeDelegate(this, location); } @CheckForNull