jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1303966 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/state/
Date Thu, 22 Mar 2012 18:43:06 GMT
Author: mduerig
Date: Thu Mar 22 18:43:05 2012
New Revision: 1303966

URL: http://svn.apache.org/viewvc?rev=1303966&view=rev
Log:
OAK-20: Remove usages of MK API from oak-jcr (WIP)
Replace PersistentNodeState and PropertyStateImpl with KernelNodeState and KernelPropertyStateImpl,
respectively

Removed:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/state/PersistentNodeState.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/state/PropertyStateImpl.java
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelPropertyState.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/state/ChangeTree.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/state/TransientNodeState.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.java?rev=1303966&r1=1303965&r2=1303966&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.java
Thu Mar 22 18:43:05 2012
@@ -37,7 +37,7 @@ import java.util.Map;
  * Basic {@link NodeState} implementation based on the {@link MicroKernel}
  * interface. This class makes an attempt to load data lazily.
  */
-class KernelNodeState extends AbstractNodeState {
+public class KernelNodeState extends AbstractNodeState { // fixme make package private
 
     /**
      * Maximum number of child nodes kept in memory.
@@ -85,10 +85,12 @@ class KernelNodeState extends AbstractNo
                     }
                     childNodes.put(name, new KernelNodeState(
                             kernel, childPath, revision));
-                } else if (reader.matches(JsopTokenizer.NUMBER) ||
-                        reader.matches(JsopTokenizer.STRING)) {
+                } else if (reader.matches(JsopTokenizer.NUMBER)) {
                     properties.put(name, new KernelPropertyState(
                             name, reader.getToken()));
+                } else if (reader.matches(JsopTokenizer.STRING)) {
+                    properties.put(name, new KernelPropertyState(
+                            name, '"' + reader.getToken() + '"'));
                 } else if (reader.matches(JsopTokenizer.TRUE)) {
                     properties.put(name, new KernelPropertyState(
                             name, "true"));

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelPropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelPropertyState.java?rev=1303966&r1=1303965&r2=1303966&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelPropertyState.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelPropertyState.java
Thu Mar 22 18:43:05 2012
@@ -20,7 +20,7 @@ package org.apache.jackrabbit.oak.kernel
 
 import org.apache.jackrabbit.mk.model.AbstractPropertyState;
 
-class KernelPropertyState extends AbstractPropertyState {
+public class KernelPropertyState extends AbstractPropertyState { // fixme make package private
 
     private final String name;
 

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java?rev=1303966&r1=1303965&r2=1303966&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
Thu Mar 22 18:43:05 2012
@@ -20,9 +20,11 @@ import org.apache.jackrabbit.JcrConstant
 import org.apache.jackrabbit.commons.iterator.NodeIteratorAdapter;
 import org.apache.jackrabbit.commons.iterator.PropertyIteratorAdapter;
 import org.apache.jackrabbit.mk.model.PropertyState;
+import org.apache.jackrabbit.oak.jcr.json.FullJsonParser;
 import org.apache.jackrabbit.oak.jcr.json.JsonValue;
 import org.apache.jackrabbit.oak.jcr.json.JsonValue.JsonAtom;
-import org.apache.jackrabbit.oak.jcr.state.PropertyStateImpl;
+import org.apache.jackrabbit.oak.jcr.json.JsonValue.Type;
+import org.apache.jackrabbit.oak.jcr.json.UnescapingJsonTokenizer;
 import org.apache.jackrabbit.oak.jcr.state.TransientNodeState;
 import org.apache.jackrabbit.oak.jcr.util.Function1;
 import org.apache.jackrabbit.oak.jcr.util.ItemNameMatcher;
@@ -850,8 +852,26 @@ public class NodeImpl extends ItemImpl i
     private Iterator<Property> propertyIterator(Iterator<PropertyState> properties)
{
         return Iterators.map(properties, new Function1<PropertyState, Property>() {
             @Override
-            public Property apply(PropertyState state) { // fixme don't cast, see OAK-16
-                JsonValue value = ((PropertyStateImpl) state).getValue();
+            public Property apply(PropertyState state) {
+                // fixme: use Scalar class
+                JsonValue value;
+                String v = state.getEncodedValue();
+                if (v.startsWith("[")) {
+                    value = FullJsonParser.parseArray(new UnescapingJsonTokenizer(v));
+                }
+                else if (v.startsWith("\"")) {
+                    value =  new JsonAtom(v.substring(1, v.length() - 1), Type.STRING);
+                }
+                else if ("true".equalsIgnoreCase(v)) {
+                    value = JsonAtom.TRUE;
+                }
+                else if ("false".equalsIgnoreCase(v)) {
+                    value = JsonAtom.FALSE;
+                }
+                else {
+                    value = new JsonAtom(v, Type.NUMBER);
+                }
+
                 return PropertyImpl.create(sessionContext, NodeImpl.this.state, state.getName(),
value);
             }
         });

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/state/ChangeTree.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/state/ChangeTree.java?rev=1303966&r1=1303965&r2=1303966&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/state/ChangeTree.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/state/ChangeTree.java
Thu Mar 22 18:43:05 2012
@@ -21,13 +21,14 @@ package org.apache.jackrabbit.oak.jcr.st
 
 import org.apache.commons.collections.map.AbstractReferenceMap;
 import org.apache.commons.collections.map.ReferenceMap;
+import org.apache.jackrabbit.mk.model.PropertyState;
 import org.apache.jackrabbit.oak.jcr.json.JsonValue;
 import org.apache.jackrabbit.oak.jcr.json.JsonValue.JsonAtom;
 import org.apache.jackrabbit.oak.jcr.util.Function1;
 import org.apache.jackrabbit.oak.jcr.util.Iterators;
 import org.apache.jackrabbit.oak.jcr.util.Path;
 import org.apache.jackrabbit.oak.jcr.util.Predicate;
-import org.apache.jackrabbit.mk.model.PropertyState;
+import org.apache.jackrabbit.oak.kernel.KernelPropertyState;
 
 import javax.jcr.ItemExistsException;
 import javax.jcr.ItemNotFoundException;
@@ -272,7 +273,7 @@ public class ChangeTree {
                     new Function1<Entry<String, JsonValue>, PropertyState>()
{
                         @Override
                         public PropertyState apply(final Entry<String, JsonValue> entry)
{
-                            return new PropertyStateImpl(entry.getKey(), entry.getValue());
+                            return new KernelPropertyState(entry.getKey(), entry.getValue().toJson());
                         }
                     });
         }

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/state/TransientNodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/state/TransientNodeState.java?rev=1303966&r1=1303965&r2=1303966&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/state/TransientNodeState.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/state/TransientNodeState.java
Thu Mar 22 18:43:05 2012
@@ -24,14 +24,18 @@ import org.apache.jackrabbit.mk.model.No
 import org.apache.jackrabbit.mk.model.PropertyState;
 import org.apache.jackrabbit.oak.jcr.SessionContext;
 import org.apache.jackrabbit.oak.jcr.SessionImpl;
+import org.apache.jackrabbit.oak.jcr.json.FullJsonParser;
 import org.apache.jackrabbit.oak.jcr.json.JsonValue;
 import org.apache.jackrabbit.oak.jcr.json.JsonValue.JsonAtom;
+import org.apache.jackrabbit.oak.jcr.json.JsonValue.Type;
+import org.apache.jackrabbit.oak.jcr.json.UnescapingJsonTokenizer;
 import org.apache.jackrabbit.oak.jcr.state.ChangeTree.NodeDelta;
 import org.apache.jackrabbit.oak.jcr.util.Function1;
 import org.apache.jackrabbit.oak.jcr.util.Iterators;
 import org.apache.jackrabbit.oak.jcr.util.PagedIterator;
 import org.apache.jackrabbit.oak.jcr.util.Path;
 import org.apache.jackrabbit.oak.jcr.util.Predicate;
+import org.apache.jackrabbit.oak.kernel.KernelNodeState;
 
 import javax.jcr.ItemExistsException;
 import javax.jcr.ItemNotFoundException;
@@ -295,7 +299,23 @@ public class TransientNodeState {
             return null;
         }
         else {
-            return ((PropertyStateImpl) state).getValue();  // fixme: don't cast, see OAK-16
+            // fixme: use Scalar class
+            String v = state.getEncodedValue();
+            if (v.startsWith("[")) {
+                return FullJsonParser.parseArray(new UnescapingJsonTokenizer(v));
+            }
+            else if (v.startsWith("\"")) {
+                return new JsonAtom(v.substring(1, v.length() - 1), Type.STRING);
+            }
+            else if ("true".equalsIgnoreCase(v)) {
+                return JsonAtom.TRUE;
+            }
+            else if ("false".equalsIgnoreCase(v)) {
+                return JsonAtom.FALSE;
+            }
+            else {
+                return new JsonAtom(v, Type.NUMBER);
+            }
         }
     }
 
@@ -308,7 +328,7 @@ public class TransientNodeState {
                 persistentNodeState = EmptyNodeState.INSTANCE;
             }
             else {
-                persistentNodeState = new PersistentNodeState(sessionContext.getMicrokernel(),
path, revision);
+                persistentNodeState = new KernelNodeState(sessionContext.getMicrokernel(),
path.toMkPath(), revision);
             }
         }
 



Mime
View raw message