jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1332673 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/kernel/ main/java/org/apache/jackrabbit/oak/util/ test/java/org/apache/jackrabbit/oak/kernel/
Date Tue, 01 May 2012 14:34:09 GMT
Author: jukka
Date: Tue May  1 14:34:09 2012
New Revision: 1332673

URL: http://svn.apache.org/viewvc?rev=1332673&view=rev
Log:
OAK-33: Values in oak-core

Move CoreValueUtil from .util to a package-private CoreValueMapper class in .kernel since
it's now only used inside that package.

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/CoreValueMapper.java
      - copied, changed from r1332671, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/CoreValueUtil.java
Removed:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/CoreValueUtil.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/KernelNodeStateBuilder.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/CoreValueFactoryTest.java

Copied: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/CoreValueMapper.java
(from r1332671, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/CoreValueUtil.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/CoreValueMapper.java?p2=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/CoreValueMapper.java&p1=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/CoreValueUtil.java&r1=1332671&r2=1332673&rev=1332673&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/CoreValueUtil.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/CoreValueMapper.java
Tue May  1 14:34:09 2012
@@ -14,15 +14,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.oak.util;
+package org.apache.jackrabbit.oak.kernel;
 
 import org.apache.jackrabbit.mk.json.JsonBuilder;
 import org.apache.jackrabbit.mk.json.JsopReader;
 import org.apache.jackrabbit.mk.json.JsopTokenizer;
 import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.api.CoreValueFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import javax.jcr.PropertyType;
 import java.util.ArrayList;
@@ -33,20 +31,13 @@ import java.util.Map;
 /**
  * CoreValueUtil provides methods to convert {@code CoreValue}s to the JSON
  * representation passed to MicroKernel and vice versa.
- *
- * TODO: review if this should be added to CoreValue/*Factory interfaces/implementation
  */
-public class CoreValueUtil {
-
-    /**
-     * logger instance
-     */
-    private static final Logger log = LoggerFactory.getLogger(CoreValueUtil.class);
+class CoreValueMapper {
 
     private static final Map<Integer, String> TYPE2HINT = new HashMap<Integer, String>();
     private static final Map<String, Integer> HINT2TYPE = new HashMap<String, Integer>();
 
-    private CoreValueUtil() {
+    private CoreValueMapper() {
     }
 
     static {
@@ -174,4 +165,5 @@ public class CoreValueUtil {
     private static boolean startsWithHint(String jsonString) {
         return jsonString.length() >= 4 && jsonString.charAt(3) == ':';
     }
+
 }
\ No newline at end of file

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=1332673&r1=1332672&r2=1332673&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 May  1 14:34:09 2012
@@ -27,7 +27,6 @@ import org.apache.jackrabbit.oak.api.Pro
 import org.apache.jackrabbit.oak.spi.state.AbstractNodeState;
 import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
-import org.apache.jackrabbit.oak.util.CoreValueUtil;
 
 import java.util.ArrayList;
 import java.util.Iterator;
@@ -99,9 +98,9 @@ class KernelNodeState extends AbstractNo
                     }
                     childNodes.put(name, new KernelNodeState(kernel, valueFactory, childPath,
revision));
                 } else if (reader.matches('[')) {
-                    properties.put(name, new PropertyStateImpl(name, CoreValueUtil.listFromJsopReader(reader,
valueFactory)));
+                    properties.put(name, new PropertyStateImpl(name, CoreValueMapper.listFromJsopReader(reader,
valueFactory)));
                 } else {
-                    CoreValue cv = CoreValueUtil.fromJsopReader(reader, valueFactory);
+                    CoreValue cv = CoreValueMapper.fromJsopReader(reader, valueFactory);
                     properties.put(name, new PropertyStateImpl(name, cv));
                 }
             } while (reader.matches(','));
@@ -228,7 +227,7 @@ class KernelNodeState extends AbstractNo
     private List<CoreValue> readArray(JsopReader reader) {
         List<CoreValue> values = new ArrayList<CoreValue>();
         while (!reader.matches(']')) {
-            values.add(CoreValueUtil.fromJsopReader(reader, valueFactory));
+            values.add(CoreValueMapper.fromJsopReader(reader, valueFactory));
             reader.matches(',');
         }
         return values;

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateBuilder.java?rev=1332673&r1=1332672&r2=1332673&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateBuilder.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateBuilder.java
Tue May  1 14:34:09 2012
@@ -28,7 +28,6 @@ import org.apache.jackrabbit.oak.commons
 import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeStateBuilder;
-import org.apache.jackrabbit.oak.util.CoreValueUtil;
 
 public class KernelNodeStateBuilder implements NodeStateBuilder {
     private final MicroKernel kernel;
@@ -102,7 +101,7 @@ public class KernelNodeStateBuilder impl
     @Override
     public void setProperty(String name, CoreValue value) {
         String targetPath = PathUtils.concat(path, name);
-        String json = CoreValueUtil.toJsonValue(value);
+        String json = CoreValueMapper.toJsonValue(value);
 
         revision[0] = kernel.commit("", "^\"" + targetPath + "\":" + json, revision[0], null);
     }
@@ -110,7 +109,7 @@ public class KernelNodeStateBuilder impl
     @Override
     public void setProperty(String name, List<CoreValue> values) {
         String targetPath = PathUtils.concat(path, name);
-        String json = CoreValueUtil.toJsonArray(values);
+        String json = CoreValueMapper.toJsonArray(values);
 
         revision[0] = kernel.commit("", "^\"" + targetPath + "\":" + json, revision[0], null);
     }
@@ -193,8 +192,8 @@ public class KernelNodeStateBuilder impl
         for (PropertyState property : nodeState.getProperties()) {
             String targetPath = PathUtils.concat(path, property.getName());
             String value = property.isArray()
-                ? CoreValueUtil.toJsonArray(property.getValues())
-                : CoreValueUtil.toJsonValue(property.getValue());
+                ? CoreValueMapper.toJsonArray(property.getValues())
+                : CoreValueMapper.toJsonValue(property.getValue());
 
             jsop.append("^\"").append(targetPath).append("\":").append(value);
         }

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/CoreValueFactoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/CoreValueFactoryTest.java?rev=1332673&r1=1332672&r2=1332673&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/CoreValueFactoryTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/CoreValueFactoryTest.java
Tue May  1 14:34:09 2012
@@ -22,7 +22,6 @@ import org.apache.jackrabbit.mk.json.Jso
 import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.api.CoreValueFactory;
 import org.apache.jackrabbit.oak.kernel.CoreValueFactoryImpl;
-import org.apache.jackrabbit.oak.util.CoreValueUtil;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -144,7 +143,7 @@ public class CoreValueFactoryTest {
     public void testToJsonValue() throws IOException {
         for (CoreValue v : singleValueMap.keySet()) {
             String json = singleValueMap.get(v);
-            assertEquals(json, CoreValueUtil.toJsonValue(v));
+            assertEquals(json, CoreValueMapper.toJsonValue(v));
         }
     }
 
@@ -153,7 +152,7 @@ public class CoreValueFactoryTest {
         for (CoreValue v : singleValueMap.keySet()) {
             String json = singleValueMap.get(v);
             JsopReader reader = new JsopTokenizer(json);
-            assertEquals(v, CoreValueUtil.fromJsopReader(reader, valueFactory));
+            assertEquals(v, CoreValueMapper.fromJsopReader(reader, valueFactory));
         }
     }
 
@@ -161,7 +160,7 @@ public class CoreValueFactoryTest {
     public void testToJsonArray() throws IOException {
         for (String json : mvValueMap.keySet()) {
             List<CoreValue> values = mvValueMap.get(json);
-            assertEquals(json, CoreValueUtil.toJsonArray(values));
+            assertEquals(json, CoreValueMapper.toJsonArray(values));
         }
     }
 
@@ -171,7 +170,7 @@ public class CoreValueFactoryTest {
             List<CoreValue> values = mvValueMap.get(json);
             JsopReader reader = new JsopTokenizer(json);
             if (reader.matches('[')) {
-                assertEquals(values, CoreValueUtil.listFromJsopReader(reader, valueFactory));
+                assertEquals(values, CoreValueMapper.listFromJsopReader(reader, valueFactory));
             }
         }
     }



Mime
View raw message