jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1305886 - 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/ oak-jcr/src/main/java/org/apache/j...
Date Tue, 27 Mar 2012 16:20:52 GMT
Author: mduerig
Date: Tue Mar 27 16:20:51 2012
New Revision: 1305886

URL: http://svn.apache.org/viewvc?rev=1305886&view=rev
Log:
OAK-33: Values in oak-core
- implement missing methods in SimplePropertyState

Added:
    jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/ScalarImpl.java
      - copied, changed from r1305874, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/ScalarImpl.java
Removed:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/ScalarImpl.java
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.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/ChangeLog.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
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/util/ValueConverter.java
    jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/store/StoredNodeAsState.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=1305886&r1=1305885&r2=1305886&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
Tue Mar 27 16:20:51 2012
@@ -27,6 +27,7 @@ import org.apache.jackrabbit.mk.model.Ab
 import org.apache.jackrabbit.mk.model.ChildNodeEntry;
 import org.apache.jackrabbit.mk.model.NodeState;
 import org.apache.jackrabbit.mk.model.PropertyState;
+import org.apache.jackrabbit.mk.model.ScalarImpl;
 
 import java.util.ArrayList;
 import java.util.Iterator;

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=1305886&r1=1305885&r2=1305886&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
Tue Mar 27 16:20:51 2012
@@ -17,7 +17,7 @@
 package org.apache.jackrabbit.oak.jcr;
 
 import org.apache.jackrabbit.JcrConstants;
-import org.apache.jackrabbit.oak.kernel.ScalarImpl;
+import org.apache.jackrabbit.mk.model.ScalarImpl;
 import org.apache.jackrabbit.commons.iterator.NodeIteratorAdapter;
 import org.apache.jackrabbit.commons.iterator.PropertyIteratorAdapter;
 import org.apache.jackrabbit.mk.model.PropertyState;

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/state/ChangeLog.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/state/ChangeLog.java?rev=1305886&r1=1305885&r2=1305886&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/state/ChangeLog.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/state/ChangeLog.java
Tue Mar 27 16:20:51 2012
@@ -19,7 +19,7 @@
 
 package org.apache.jackrabbit.oak.jcr.state;
 
-import org.apache.jackrabbit.oak.kernel.ScalarImpl;
+import org.apache.jackrabbit.mk.model.ScalarImpl;
 import org.apache.jackrabbit.mk.model.PropertyState;
 import org.apache.jackrabbit.oak.jcr.util.Path;
 import org.apache.jackrabbit.oak.kernel.KernelPropertyState;

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=1305886&r1=1305885&r2=1305886&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
Tue Mar 27 16:20:51 2012
@@ -21,7 +21,7 @@ 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.oak.kernel.ScalarImpl;
+import org.apache.jackrabbit.mk.model.ScalarImpl;
 import org.apache.jackrabbit.mk.model.PropertyState;
 import org.apache.jackrabbit.oak.jcr.util.Iterators;
 import org.apache.jackrabbit.oak.jcr.util.Path;

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=1305886&r1=1305885&r2=1305886&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
Tue Mar 27 16:20:51 2012
@@ -20,7 +20,7 @@
 package org.apache.jackrabbit.oak.jcr.state;
 
 import org.apache.jackrabbit.mk.model.Scalar;
-import org.apache.jackrabbit.oak.kernel.ScalarImpl;
+import org.apache.jackrabbit.mk.model.ScalarImpl;
 import org.apache.jackrabbit.mk.model.ChildNodeEntry;
 import org.apache.jackrabbit.mk.model.NodeState;
 import org.apache.jackrabbit.mk.model.PropertyState;

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/util/ValueConverter.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/util/ValueConverter.java?rev=1305886&r1=1305885&r2=1305886&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/util/ValueConverter.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/util/ValueConverter.java
Tue Mar 27 16:20:51 2012
@@ -20,7 +20,7 @@
 package org.apache.jackrabbit.oak.jcr.util;
 
 import org.apache.jackrabbit.mk.model.Scalar;
-import org.apache.jackrabbit.oak.kernel.ScalarImpl;
+import org.apache.jackrabbit.mk.model.ScalarImpl;
 
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;

Copied: jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/ScalarImpl.java
(from r1305874, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/ScalarImpl.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/ScalarImpl.java?p2=jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/ScalarImpl.java&p1=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/ScalarImpl.java&r1=1305874&r2=1305886&rev=1305886&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/ScalarImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/ScalarImpl.java
Tue Mar 27 16:20:51 2012
@@ -14,9 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.oak.kernel;
-
-import org.apache.jackrabbit.mk.model.Scalar;
+package org.apache.jackrabbit.mk.model;
 
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;

Modified: jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/store/StoredNodeAsState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/store/StoredNodeAsState.java?rev=1305886&r1=1305885&r2=1305886&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/store/StoredNodeAsState.java
(original)
+++ jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/store/StoredNodeAsState.java
Tue Mar 27 16:20:51 2012
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.mk.store;
 
+import org.apache.jackrabbit.mk.json.JsopReader;
+import org.apache.jackrabbit.mk.json.JsopTokenizer;
 import org.apache.jackrabbit.mk.model.AbstractChildNodeEntry;
 import org.apache.jackrabbit.mk.model.AbstractNodeState;
 import org.apache.jackrabbit.mk.model.AbstractPropertyState;
@@ -25,10 +27,13 @@ import org.apache.jackrabbit.mk.model.Id
 import org.apache.jackrabbit.mk.model.NodeState;
 import org.apache.jackrabbit.mk.model.PropertyState;
 import org.apache.jackrabbit.mk.model.Scalar;
+import org.apache.jackrabbit.mk.model.ScalarImpl;
 import org.apache.jackrabbit.mk.model.StoredNode;
 
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 
 class StoredNodeAsState extends AbstractNodeState {
@@ -47,11 +52,10 @@ class StoredNodeAsState extends Abstract
     }
 
     private static class SimplePropertyState extends AbstractPropertyState {
-
         private final String name;
-
         private final String value;
 
+        // todo make name and value not nullable
         public SimplePropertyState(String name, String value) {
             this.name = name;
             this.value = value;
@@ -69,17 +73,46 @@ class StoredNodeAsState extends Abstract
 
         @Override
         public boolean isArray() {
-            return false; // todo implement isMultiValued
+            return !value.isEmpty() && value.charAt(0) == '[';
         }
 
         @Override
         public Scalar getScalar() {
-            return null; // todo implement getValue
+            if (isArray()) {
+                throw new IllegalStateException("Array cannot be accessed as scalar");
+            }
+
+            return readScalar(new JsopTokenizer(value));
         }
 
         @Override
         public Iterable<Scalar> getArray() {
-            return null; // todo implement getValues
+            if (!isArray()) {
+                throw new IllegalStateException("Scalar cannot be accessed as array");
+            }
+
+            List<Scalar> scalars = new ArrayList<Scalar>();
+            JsopReader reader = new JsopTokenizer(value);
+            reader.read('[');
+            while (!reader.matches(']')) {
+                scalars.add(readScalar(reader));
+                reader.matches(',');
+            }
+            return scalars;
+        }
+
+        private static Scalar readScalar(JsopReader reader) {
+            if (reader.matches(JsopTokenizer.NUMBER)) {
+                return ScalarImpl.numberScalar(reader.getToken());
+            } else if (reader.matches(JsopTokenizer.STRING)) {
+                return ScalarImpl.stringScalar(reader.getToken());
+            } else if (reader.matches(JsopTokenizer.TRUE)) {
+                return ScalarImpl.booleanScalar(true);
+            } else if (reader.matches(JsopTokenizer.FALSE)) {
+                return ScalarImpl.booleanScalar(false);
+            } else {
+                throw new IllegalArgumentException("Unexpected token: " + reader.getToken());
+            }
         }
 
     }
@@ -102,18 +135,22 @@ class StoredNodeAsState extends Abstract
     @Override
     public Iterable<PropertyState> getProperties() {
         return new Iterable<PropertyState>() {
+            @Override
             public Iterator<PropertyState> iterator() {
                 final Iterator<Map.Entry<String, String>> iterator =
                         node.getProperties().entrySet().iterator();
                 return new Iterator<PropertyState>() {
+                    @Override
                     public boolean hasNext() {
                         return iterator.hasNext();
                     }
+                    @Override
                     public PropertyState next() {
                         Map.Entry<String, String> entry = iterator.next();
                         return new SimplePropertyState(
                                 entry.getKey(), entry.getValue());
                     }
+                    @Override
                     public void remove() {
                         throw new UnsupportedOperationException();
                     }
@@ -146,16 +183,20 @@ class StoredNodeAsState extends Abstract
             return Collections.emptyList();
         } else {
             return new Iterable<ChildNodeEntry>() {
+                @Override
                 public Iterator<ChildNodeEntry> iterator() {
                     final Iterator<ChildNode> iterator =
                             node.getChildNodeEntries((int) offset, count);
                     return new Iterator<ChildNodeEntry>() {
+                        @Override
                         public boolean hasNext() {
                             return iterator.hasNext();
                         }
+                        @Override
                         public ChildNodeEntry next() {
                             return getChildNodeEntry(iterator.next());
                         }
+                        @Override
                         public void remove() {
                             throw new UnsupportedOperationException();
                         }
@@ -168,9 +209,11 @@ class StoredNodeAsState extends Abstract
     private ChildNodeEntry getChildNodeEntry(
             final org.apache.jackrabbit.mk.model.ChildNode entry) {
         return new AbstractChildNodeEntry() {
+            @Override
             public String getName() {
                 return entry.getName();
             }
+            @Override
             public NodeState getNode() {
                 try {
                     StoredNode child = provider.getNode(entry.getId());



Mime
View raw message