jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1298002 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/StoredNodeAsState.java
Date Wed, 07 Mar 2012 16:00:49 GMT
Author: jukka
Date: Wed Mar  7 16:00:48 2012
New Revision: 1298002

URL: http://svn.apache.org/viewvc?rev=1298002&view=rev
Log:
OAK-3: Internal tree model

Use the abstract base classes and add an optimized equals() implementation based on the content
id

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/StoredNodeAsState.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/StoredNodeAsState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/StoredNodeAsState.java?rev=1298002&r1=1298001&r2=1298002&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/StoredNodeAsState.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/store/StoredNodeAsState.java
Wed Mar  7 16:00:48 2012
@@ -21,11 +21,14 @@ import java.util.Iterator;
 import java.util.Map;
 
 import org.apache.jackrabbit.mk.model.StoredNode;
+import org.apache.jackrabbit.oak.model.AbstractChildNodeEntry;
+import org.apache.jackrabbit.oak.model.AbstractNodeState;
+import org.apache.jackrabbit.oak.model.AbstractPropertyState;
 import org.apache.jackrabbit.oak.model.ChildNodeEntry;
 import org.apache.jackrabbit.oak.model.NodeState;
 import org.apache.jackrabbit.oak.model.PropertyState;
 
-class StoredNodeAsState implements NodeState {
+class StoredNodeAsState extends AbstractNodeState {
 
     private final StoredNode node;
 
@@ -36,7 +39,7 @@ class StoredNodeAsState implements NodeS
         this.provider = provider;
     }
 
-    private static class SimplePropertyState implements PropertyState {
+    private static class SimplePropertyState extends AbstractPropertyState {
 
         private final String name;
 
@@ -47,16 +50,19 @@ class StoredNodeAsState implements NodeS
             this.value = value;
         }
 
+        @Override
         public String getName() {
             return name;
         }
 
+        @Override
         public String getEncodedValue() {
             return value;
         }
 
     }
 
+    @Override
     public PropertyState getProperty(String name) {
         String value = node.getProperties().get(name);
         if (value != null) {
@@ -66,10 +72,12 @@ class StoredNodeAsState implements NodeS
         }
     }
 
+    @Override
     public long getPropertyCount() {
         return node.getProperties().size();
     }
 
+    @Override
     public Iterable<PropertyState> getProperties() {
         return new Iterable<PropertyState>() {
             public Iterator<PropertyState> iterator() {
@@ -92,6 +100,7 @@ class StoredNodeAsState implements NodeS
         };
     }
 
+    @Override
     public NodeState getChildNode(String name) {
         org.apache.jackrabbit.mk.model.ChildNodeEntry entry =
                 node.getChildNodeEntry(name);
@@ -102,10 +111,12 @@ class StoredNodeAsState implements NodeS
         }
     }
 
+    @Override
     public long getChildNodeCount() {
         return node.getChildNodeCount();
     }
 
+    @Override
     public Iterable<ChildNodeEntry> getChildNodeEntries(
             final long offset, final long length) {
         if (length < -1) {
@@ -139,7 +150,7 @@ class StoredNodeAsState implements NodeS
 
     private ChildNodeEntry getChildNodeEntry(
             final org.apache.jackrabbit.mk.model.ChildNodeEntry entry) {
-        return new ChildNodeEntry() {
+        return new AbstractChildNodeEntry() {
             public String getName() {
                 return entry.getName();
             }
@@ -154,4 +165,16 @@ class StoredNodeAsState implements NodeS
         };
     }
 
+    @Override
+    public boolean equals(Object that) {
+        if (that instanceof StoredNodeAsState) {
+            StoredNodeAsState other = (StoredNodeAsState) that;
+            if (provider == other.provider
+                    && node.getId().equals(other.node.getId())) {
+                return true;
+            }
+        }
+        return super.equals(that);
+    }
+
 }



Mime
View raw message