jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1243551 - in /jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state: ChangeTree.java NodeState.java
Date Mon, 13 Feb 2012 15:03:15 GMT
Author: mduerig
Date: Mon Feb 13 15:03:15 2012
New Revision: 1243551

URL: http://svn.apache.org/viewvc?rev=1243551&view=rev
Log:
Microkernel based prototype of JCR implementation (WIP)
- refactor property handling in transient space 

Modified:
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/ChangeTree.java
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/NodeState.java

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/ChangeTree.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/ChangeTree.java?rev=1243551&r1=1243550&r2=1243551&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/ChangeTree.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/ChangeTree.java
Mon Feb 13 15:03:15 2012
@@ -22,6 +22,7 @@ package org.apache.jackrabbit.state;
 import org.apache.commons.collections.map.ReferenceMap;
 import org.apache.jackrabbit.Path;
 import org.apache.jackrabbit.json.JsonValue;
+import org.apache.jackrabbit.json.JsonValue.JsonAtom;
 import org.apache.jackrabbit.spi.commons.iterator.Iterators;
 import org.apache.jackrabbit.spi.commons.iterator.Predicate;
 
@@ -229,7 +230,8 @@ public class ChangeTree {
 
         /**
          * @param name
-         * @return {@code true} iff this node has a property with the given {@code name}.
+         * @return {@code true} iff a property with the given name has been added,
+         * removed or modified.
          */
         public boolean hasProperty(String name) {
             return properties.containsKey(name);
@@ -237,25 +239,18 @@ public class ChangeTree {
 
         /**
          * @param name
-         * @return  the property with the given {@code name} or {@code null} if the property
-         * has been removed ({@link #hasProperty(String)} {@code true}) or does not exist
-         * ({@link #hasProperty(String)} {@code false}).
+         * @return  the value of the property with the given {@code name}, JSON {@code null}
if the
+         * property has been removed or {@code null} if if does not exist.
          */
         public JsonValue getProperty(String name) {
             return properties.get(name);
         }
 
         /**
-         * @return  an iterator of all added/modified properties.
+         * @return  an iterator of all added, removed and modified properties.
          */
         public Iterator<Entry<String, JsonValue>> getProperties() {
-            return Iterators.filterIterator(properties.entrySet().iterator(),
-                new Predicate<Entry<String, JsonValue>>() {
-                    @Override
-                    public boolean evaluate(Entry<String, JsonValue> entry) {
-                        return entry.getValue() != null;
-                    }
-            });
+            return properties.entrySet().iterator();
         }
 
         /**
@@ -323,12 +318,16 @@ public class ChangeTree {
 
         /**
          * Set the property with the given {@code name} to {@code value} or remove the
-         * property if {@code value} is {@code null}.
+         * property if {@code value} is {@code null} or JSON {@code null}.
          * @param name
          * @param value
          */
         public void setValue(String name, JsonValue value) {
-            if (value == null && properties.containsKey(name) && properties.get(name)
!= null) {
+            if (value == null) {
+                value = JsonAtom.NULL;
+            }
+            
+            if (value.isNull() && properties.containsKey(name) && properties.get(name)
!= JsonAtom.NULL) {
                 properties.remove(name);
             }
             else {

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/NodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/NodeState.java?rev=1243551&r1=1243550&r2=1243551&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/NodeState.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/NodeState.java
Mon Feb 13 15:03:15 2012
@@ -23,6 +23,7 @@ import org.apache.jackrabbit.Path;
 import org.apache.jackrabbit.SessionImpl.Context;
 import org.apache.jackrabbit.json.FullJsonParser;
 import org.apache.jackrabbit.json.JsonValue;
+import org.apache.jackrabbit.json.JsonValue.JsonAtom;
 import org.apache.jackrabbit.json.JsonValue.JsonObject;
 import org.apache.jackrabbit.json.UnescapingJsonTokenizer;
 import org.apache.jackrabbit.mk.api.MicroKernel;
@@ -147,11 +148,12 @@ public class NodeState {
     }
 
     public boolean isPropertyNew(String name) {
-        return nodeDelta.getProperty(name) != null && getPersistedPropertyValue(name)
== null;
+        JsonValue value = nodeDelta.getProperty(name);
+        return value != null && !value.isNull() && getPersistedPropertyValue(name)
== null;
     }
 
     public boolean isPropertyModified(String name) {
-        return nodeDelta.getProperty(name) != null;
+        return nodeDelta.hasProperty(name);
     }
 
     public void removeProperty(String name) {
@@ -235,14 +237,13 @@ public class NodeState {
     }
 
     private JsonValue getPropertyValueOrNull(String name) {
-        if (nodeDelta.hasProperty(name)) {
-            JsonValue value = nodeDelta.getProperty(name);
-            if (value != null) {
-                return value;
-            }
+        JsonValue value = nodeDelta.getProperty(name);
+        if (value == null) {
+            return getPersistedPropertyValue(name);
+        }
+        else {
+            return value == JsonAtom.NULL ? null : value;
         }
-
-        return getPersistedPropertyValue(name);
     }
 
     private JsonValue getPersistedPropertyValue(String name) {



Mime
View raw message