jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1487393 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/plugins/memory/ModifiedNodeState.java test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilderTest.java
Date Wed, 29 May 2013 08:09:30 GMT
Author: jukka
Date: Wed May 29 08:09:29 2013
New Revision: 1487393

URL: http://svn.apache.org/r1487393
Log:
OAK-781: Clarify / fix effects of MISSING_NODE as base state of NodeBuilder

Add a way to "squeeze" ModifiedNodeState instances into equivalent MemoryNodeStates

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/ModifiedNodeState.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilderTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/ModifiedNodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/ModifiedNodeState.java?rev=1487393&r1=1487392&r2=1487393&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/ModifiedNodeState.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/ModifiedNodeState.java
Wed May 29 08:09:29 2013
@@ -94,6 +94,27 @@ public class ModifiedNodeState extends A
         }
     }
 
+    /**
+     * "Squeezes" {@link ModifiedNodeState} instances into equivalent
+     * {@link MemoryNodeState}s. Other kinds of states are returned as-is.
+     */
+    public static NodeState squeeze(NodeState state) {
+        if (state instanceof ModifiedNodeState) {
+            Map<String, PropertyState> properties = newHashMap();
+            for (PropertyState property : state.getProperties()) {
+                properties.put(property.getName(), property);
+            }
+
+            Map<String, NodeState> nodes = newHashMap();
+            for (ChildNodeEntry child : state.getChildNodeEntries()) {
+                nodes.put(child.getName(), squeeze(child.getNodeState()));
+            }
+
+            state = new MemoryNodeState(properties, nodes);
+        }
+        return state;
+    }
+
 
     static long getPropertyCount(
             NodeState base, Map<String, PropertyState> properties) {

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilderTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilderTest.java?rev=1487393&r1=1487392&r2=1487393&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilderTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilderTest.java
Wed May 29 08:09:29 2013
@@ -47,7 +47,7 @@ public class MemoryNodeBuilderTest {
         builder.child("x").child("q");
         builder.child("y");
         builder.child("z");
-        base = builder.getNodeState();
+        base = ModifiedNodeState.squeeze(builder.getNodeState());
     }
 
     @Test



Mime
View raw message