jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1406544 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/api/ oak-core/src/main/java/org/apache/jackrabbit/oak/core/ oak-core/src/main/java/org/apache/jackrabbit/oak/util/ oak-jcr/src/main/java/org/apache/jackra...
Date Wed, 07 Nov 2012 11:01:39 GMT
Author: mduerig
Date: Wed Nov  7 11:01:39 2012
New Revision: 1406544

URL: http://svn.apache.org/viewvc?rev=1406544&view=rev
Log:
OAK-427: ItemDelegate has dependency to TreeImpl#NullLocation

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/TreeLocation.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/LocationUtil.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemDelegate.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/TreeLocation.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/TreeLocation.java?rev=1406544&r1=1406543&r2=1406544&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/TreeLocation.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/TreeLocation.java
Wed Nov  7 11:01:39 2012
@@ -37,6 +37,61 @@ import org.apache.jackrabbit.oak.api.Tre
 public interface TreeLocation {
 
     /**
+     * This {@code TreeLocation} refers to an invalid location in a tree. That is
+     * to a location where no item resides.
+     */
+    TreeLocation NULL = new TreeLocation() {
+
+        /**
+         * @return  {@code NULL}
+         */
+        @Override
+        public TreeLocation getParent() {
+            return NULL;
+        }
+
+        /**
+         * @return  {@code NULL}
+         */
+        @Override
+        public TreeLocation getChild(String relPath) {
+            return NULL;
+        }
+
+        /**
+         * @return  {@code null}
+         */
+        @Override
+        public String getPath() {
+            return null;
+        }
+
+        /**
+         * @return  {@code null}
+         */
+        @Override
+        public Tree getTree() {
+            return null;
+        }
+
+        /**
+         * @return  {@code null}
+         */
+        @Override
+        public PropertyState getProperty() {
+            return null;
+        }
+
+        /**
+         * @return  {@code null}
+         */
+        @Override
+        public Status getStatus() {
+            return null;
+        }
+    };
+
+    /**
      * Navigate to the parent
      * @return  a {@code TreeLocation} for the parent of this location.
      */

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java?rev=1406544&r1=1406543&r2=1406544&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
Wed Nov  7 11:01:39 2012
@@ -626,7 +626,7 @@ public class TreeImpl implements Tree {
         @Override
         public TreeLocation getParent() {
             return tree.parent == null
-                ? NullLocation.INSTANCE
+                ? TreeLocation.NULL
                 : new NodeLocation(tree.parent);
         }
 
@@ -642,7 +642,7 @@ public class TreeImpl implements Tree {
             for (String name : PathUtils.elements(parentPath)) {
                 child = child.internalGetChild(name);
                 if (child == null) {
-                    return NullLocation.INSTANCE;
+                    return TreeLocation.NULL;
                 }
             }
 
@@ -654,7 +654,7 @@ public class TreeImpl implements Tree {
             else {
                 child = child.internalGetChild(name);
                 return child == null
-                    ? NullLocation.INSTANCE
+                    ? TreeLocation.NULL
                     : new NodeLocation(child);
             }
         }
@@ -696,7 +696,7 @@ public class TreeImpl implements Tree {
 
         @Override
         public TreeLocation getChild(String relPath) {
-            return NullLocation.INSTANCE;
+            return TreeLocation.NULL;
         }
 
         @Override
@@ -740,43 +740,6 @@ public class TreeImpl implements Tree {
         }
     }
 
-    public static class NullLocation implements TreeLocation {
-        public static final NullLocation INSTANCE = new NullLocation();
-
-        private NullLocation() {
-        }
-
-        @Override
-        public TreeLocation getParent() {
-            return this;
-        }
-
-        @Override
-        public TreeLocation getChild(String relPath) {
-            return this;
-        }
-
-        @Override
-        public String getPath() {
-            return null;
-        }
-
-        @Override
-        public Tree getTree() {
-            return null;
-        }
-
-        @Override
-        public PropertyState getProperty() {
-            return null;
-        }
-
-        @Override
-        public Status getStatus() {
-            return null;
-        }
-    }
-
 }
 
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/LocationUtil.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/LocationUtil.java?rev=1406544&r1=1406543&r2=1406544&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/LocationUtil.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/LocationUtil.java
Wed Nov  7 11:01:39 2012
@@ -20,7 +20,6 @@ import javax.annotation.Nonnull;
 
 import org.apache.jackrabbit.oak.api.TreeLocation;
 import org.apache.jackrabbit.oak.commons.PathUtils;
-import org.apache.jackrabbit.oak.core.TreeImpl;
 import org.apache.jackrabbit.util.Text;
 
 /**
@@ -32,7 +31,7 @@ public class LocationUtil {
     public static TreeLocation getTreeLocation(TreeLocation parentLocation, String relativePath)
{
         TreeLocation targetLocation = parentLocation;
         String[] segments = Text.explode(relativePath, '/', false);
-        for (int i = 0; i < segments.length && targetLocation != TreeImpl.NullLocation.INSTANCE;
i++) {
+        for (int i = 0; i < segments.length && targetLocation != TreeLocation.NULL;
i++) {
             String segment = segments[i];
             if (PathUtils.denotesCurrent(segment)) {
                 continue;

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemDelegate.java?rev=1406544&r1=1406543&r2=1406544&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemDelegate.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemDelegate.java
Wed Nov  7 11:01:39 2012
@@ -24,7 +24,6 @@ import javax.jcr.InvalidItemStateExcepti
 import org.apache.jackrabbit.oak.api.Tree.Status;
 import org.apache.jackrabbit.oak.api.TreeLocation;
 import org.apache.jackrabbit.oak.commons.PathUtils;
-import org.apache.jackrabbit.oak.core.TreeImpl.NullLocation;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 
@@ -118,7 +117,7 @@ public abstract class ItemDelegate {
     @Nonnull
     public TreeLocation getLocation() throws InvalidItemStateException {
         TreeLocation location = getLocationOrNull();
-        if (location == NullLocation.INSTANCE) {
+        if (location == TreeLocation.NULL) {
             throw new InvalidItemStateException("Item is stale");
         }
         return location;
@@ -140,7 +139,7 @@ public abstract class ItemDelegate {
      */
     @CheckForNull
     private synchronized TreeLocation getLocationOrNull() {
-        if (location != NullLocation.INSTANCE && sessionDelegate.getRevision() !=
revision) {
+        if (location != TreeLocation.NULL && sessionDelegate.getRevision() != revision)
{
             location = sessionDelegate.getLocation(location.getPath());
             revision = sessionDelegate.getRevision();
         }



Mime
View raw message