jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1243523 - in /jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit: PropertyImpl.java WorkspaceImpl.java json/JsonValue.java state/NodeState.java
Date Mon, 13 Feb 2012 14:09:23 GMT
Author: mduerig
Date: Mon Feb 13 14:09:23 2012
New Revision: 1243523

URL: http://svn.apache.org/viewvc?rev=1243523&view=rev
Log:
Microkernel based prototype of JCR implementation (WIP)
- add utility methods 

Modified:
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/PropertyImpl.java
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/WorkspaceImpl.java
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/json/JsonValue.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/PropertyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/PropertyImpl.java?rev=1243523&r1=1243522&r2=1243523&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/PropertyImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/PropertyImpl.java
Mon Feb 13 14:09:23 2012
@@ -21,7 +21,6 @@ package org.apache.jackrabbit;
 
 import org.apache.jackrabbit.SessionImpl.Context;
 import org.apache.jackrabbit.json.JsonValue;
-import org.apache.jackrabbit.json.JsonValue.Type;
 import org.apache.jackrabbit.state.NodeState;
 import org.apache.jackrabbit.utils.ValueConverter;
 
@@ -256,7 +255,7 @@ public class PropertyImpl extends ItemIm
 
     @Override
     public Value getValue() throws RepositoryException {
-        if (value.type().compound()) {
+        if (!value.isAtom()) {
             throw new ValueFormatException(value.toJson());
         }
 
@@ -266,7 +265,7 @@ public class PropertyImpl extends ItemIm
 
     @Override
     public Value[] getValues() throws RepositoryException {
-        if (value.type() != Type.ARRAY) {
+        if (!value.isArray()) {
             throw new ValueFormatException(value.toJson());
         }
 
@@ -378,7 +377,7 @@ public class PropertyImpl extends ItemIm
 
     @Override
     public boolean isMultiple() throws RepositoryException {
-        return value.type() == JsonValue.Type.ARRAY;
+        return value.isArray();
     }
 
 }

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/WorkspaceImpl.java?rev=1243523&r1=1243522&r2=1243523&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/WorkspaceImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/WorkspaceImpl.java
Mon Feb 13 14:09:23 2012
@@ -23,7 +23,6 @@ import org.apache.jackrabbit.SessionImpl
 import org.apache.jackrabbit.json.FullJsonParser;
 import org.apache.jackrabbit.json.JsonValue;
 import org.apache.jackrabbit.json.JsonValue.JsonObject;
-import org.apache.jackrabbit.json.JsonValue.Type;
 import org.apache.jackrabbit.json.UnescapingJsonTokenizer;
 import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.xml.sax.ContentHandler;
@@ -140,7 +139,7 @@ public class WorkspaceImpl implements Wo
 
         List<String> workspaces = new ArrayList<String>();
         for (Entry<String, JsonValue> entry : jsonObject.value().entrySet()) {
-            if (entry.getValue().type() == Type.OBJECT) {
+            if (entry.getValue().isObject()) {
                 workspaces.add(entry.getKey());
             }
         }

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/json/JsonValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/json/JsonValue.java?rev=1243523&r1=1243522&r2=1243523&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/json/JsonValue.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/json/JsonValue.java
Mon Feb 13 14:09:23 2012
@@ -229,6 +229,48 @@ public abstract class JsonValue {
     public abstract void accept(Visitor visitor);
 
     /**
+     * @return {@code true} iff {@code this} is an instance of {@code JsonAtom}
+     */
+    public boolean isAtom() {
+        return !type().compound();
+    }
+
+    /**
+     * @return {@code true} iff {@code this} is an instance of {@code JsonArray}
+     */
+    public boolean isArray() {
+        return type() == Type.ARRAY;
+    }
+
+    /**
+     * @return {@code true} iff {@code this} is an instance of {@code JsonObject}
+     */
+    public boolean isObject() {
+        return type() == Type.OBJECT;
+    }
+
+    /**
+     * @return {@code true} iff {@code this} represents a JSON null value
+     */
+    public boolean isNull() {
+        return this == JsonAtom.NULL || equals(JsonAtom.NULL);
+    }
+
+    /**
+     * @return {@code true} iff {@code this} represents a JSON true value
+     */
+    public boolean isTrue() {
+        return this == JsonAtom.TRUE || equals(JsonAtom.TRUE);
+    }
+
+    /**
+     * @return {@code true} iff {@code this} represents a JSON false value
+     */
+    public boolean isFalse() {
+        return this == JsonAtom.FALSE || equals(JsonAtom.FALSE);
+    }
+
+    /**
      * @return {@code this} as {@code JsonAtom}
      * @throws UnsupportedOperationException if {@code this} is not an instance of {@code
JsonAtom}
      */
@@ -306,18 +348,6 @@ public abstract class JsonValue {
             this(token.text(), valueType(token.type()));
         }
         
-        public boolean isNull() {
-            return this == NULL || equals(NULL);
-        }
-        
-        public boolean isTrue() {
-            return this == TRUE || equals(TRUE);
-        }
-        
-        public boolean isFalse() {
-            return this == FALSE || equals(FALSE);
-        }
-
         @Override
         public JsonAtom asAtom() {
             return this;

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=1243523&r1=1243522&r2=1243523&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 14:09:23 2012
@@ -24,7 +24,6 @@ import org.apache.jackrabbit.SessionImpl
 import org.apache.jackrabbit.json.FullJsonParser;
 import org.apache.jackrabbit.json.JsonValue;
 import org.apache.jackrabbit.json.JsonValue.JsonObject;
-import org.apache.jackrabbit.json.JsonValue.Type;
 import org.apache.jackrabbit.json.UnescapingJsonTokenizer;
 import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.spi.commons.iterator.Iterators;
@@ -207,7 +206,7 @@ public class NodeState {
     };
 
     private static boolean isNode(JsonValue value) {
-        return value.type() == Type.OBJECT;
+        return value.isObject();
     }
 
     private Iterator<NodeState> getPersistedChildNodeStates() {



Mime
View raw message