jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1305361 - 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 Mon, 26 Mar 2012 14:04:09 GMT
Author: jukka
Date: Mon Mar 26 14:04:09 2012
New Revision: 1305361

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

Avoid using the term "value" in PropertyState to reduce chance of confusion with JCR Values.

Change the return type of getArray (was getValues) to Iterable for simplicity.

Modified:
    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/PropertyImpl.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/model/PropertyState.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/KernelPropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelPropertyState.java?rev=1305361&r1=1305360&r2=1305361&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
Mon Mar 26 14:04:09 2012
@@ -68,22 +68,22 @@ public class KernelPropertyState extends
     }
 
     @Override
-    public boolean isMultiValued() {
+    public boolean isArray() {
         return value == null;
     }
     
     @Override
-    public Scalar getValue() {
+    public Scalar getScalar() {
         return value;
     }
-    
+
     @Override
-    public List<Scalar> getValues() {
+    public Iterable<Scalar> getArray() {
         return values;
     }
-    
-    //------------------------------------------------------------< private >--- 
-    
+
+    //------------------------------------------------------------< private >
+
     private static String encodeValue(Scalar value) {
         if (value.getType() == Type.STRING) {
             return '"' + JsonBuilder.escape(value.getString()) + '"';

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java?rev=1305361&r1=1305360&r2=1305361&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
Mon Mar 26 14:04:09 2012
@@ -357,7 +357,7 @@ public class PropertyImpl extends ItemIm
             throw new ValueFormatException(LogUtil.safeGetJCRPath(this) + " is multi-valued.");
         }
 
-        return ValueConverter.toValue(getValueFactory(), state.getValue());
+        return ValueConverter.toValue(getValueFactory(), state.getScalar());
     }
 
     @Override
@@ -367,7 +367,7 @@ public class PropertyImpl extends ItemIm
             throw new ValueFormatException(LogUtil.safeGetJCRPath(this) + " is not multi-valued.");
         }
 
-        return ValueConverter.toValues(getValueFactory(), state.getValues());
+        return ValueConverter.toValues(getValueFactory(), state.getArray());
     }
 
     /**
@@ -542,7 +542,7 @@ public class PropertyImpl extends ItemIm
      */
     @Override
     public boolean isMultiple() throws RepositoryException {
-        return state.isMultiValued();
+        return state.isArray();
     }
 
     //------------------------------------------------------------< private >---

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=1305361&r1=1305360&r2=1305361&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
Mon Mar 26 14:04:09 2012
@@ -262,7 +262,7 @@ public class ChangeTree {
                     new Predicate<PropertyState>() {
                         @Override
                         public boolean evaluate(PropertyState state) {
-                            return !state.getValue().equals(ScalarImpl.nullScalar());
+                            return !state.getScalar().equals(ScalarImpl.nullScalar());
                         }
                     });
         }
@@ -346,7 +346,7 @@ public class ChangeTree {
          */
         public void removeProperty(String name)  {
             PropertyState state = properties.get(name);
-            if (state != null && !state.isMultiValued() && !state.getValue().equals(ScalarImpl.nullScalar()))
{
+            if (state != null && !state.isArray() && !state.getScalar().equals(ScalarImpl.nullScalar()))
{
                 // remove transiently added property
                 properties.remove(name);
             }

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=1305361&r1=1305360&r2=1305361&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
Mon Mar 26 14:04:09 2012
@@ -269,11 +269,11 @@ public class TransientNodeState {
             return false;
         }
 
-        if (state.isMultiValued()) {
+        if (state.isArray()) {
             return getPersistedPropertyState(name) == null;
         }
         else {
-            Scalar value = state.getValue();
+            Scalar value = state.getScalar();
             return !value.equals(ScalarImpl.nullScalar()) && getPersistedPropertyState(name)
== null;
         }
     }
@@ -307,11 +307,11 @@ public class TransientNodeState {
             return getPersistedPropertyState(name);
         }
         else {
-            if (state.isMultiValued()) {
+            if (state.isArray()) {
                 return state;
             }
             else {
-                Scalar value = state.getValue();
+                Scalar value = state.getScalar();
                 return value.equals(ScalarImpl.nullScalar())
                     ? null
                     : state;

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=1305361&r1=1305360&r2=1305361&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
Mon Mar 26 14:04:09 2012
@@ -28,7 +28,6 @@ import javax.jcr.UnsupportedRepositoryOp
 import javax.jcr.Value;
 import javax.jcr.ValueFactory;
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.List;
 
 /**
@@ -94,15 +93,13 @@ public final class ValueConverter {
         }
     }
 
-    public static Value[] toValues(ValueFactory valueFactory, Collection<Scalar> scalars)
+    public static Value[] toValues(ValueFactory valueFactory, Iterable<Scalar> scalars)
             throws UnsupportedRepositoryOperationException {
-
-        Value[] values = new Value[scalars.size()];
-        int k = 0;
+        List<Value> values = new ArrayList<Value>();
         for (Scalar scalar : scalars) {
-            values[k++] = toValue(valueFactory, scalar);
+            values.add(toValue(valueFactory, scalar));
         }
-        return values;
+        return values.toArray(new Value[values.size()]);
     }
 
 }

Modified: jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/PropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/PropertyState.java?rev=1305361&r1=1305360&r2=1305361&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/PropertyState.java
(original)
+++ jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/PropertyState.java
Mon Mar 26 14:04:09 2012
@@ -16,8 +16,6 @@
  */
 package org.apache.jackrabbit.mk.model;
 
-import java.util.Collection;
-
 /**
  * Immutable property state. A property consists of a name and
  * a JSON-encoded value.
@@ -47,17 +45,18 @@ public interface PropertyState {
      * Determine whether this is a multi valued property
      * @return  {@code true} if and only if this is a multi valued property.
      */
-    boolean isMultiValued();
+    boolean isArray();
 
     /**
      * @return  the single value of this property or {@code null} if this is a multi
      * valued property.
      */
-    Scalar getValue();
+    Scalar getScalar();
 
     /**
      * @return  an immutable collection of the values of this multi valued property or
      * {@code null} if this is not a multi valued property.
      */
-    Collection<Scalar> getValues();
+    Iterable<Scalar> getArray();
+
 }

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=1305361&r1=1305360&r2=1305361&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
Mon Mar 26 14:04:09 2012
@@ -27,7 +27,6 @@ import org.apache.jackrabbit.mk.model.Pr
 import org.apache.jackrabbit.mk.model.Scalar;
 import org.apache.jackrabbit.mk.model.StoredNode;
 
-import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.Map;
@@ -69,17 +68,17 @@ class StoredNodeAsState extends Abstract
         }
 
         @Override
-        public boolean isMultiValued() {
+        public boolean isArray() {
             return false; // todo implement isMultiValued
         }
 
         @Override
-        public Scalar getValue() {
+        public Scalar getScalar() {
             return null; // todo implement getValue
         }
 
         @Override
-        public Collection<Scalar> getValues() {
+        public Iterable<Scalar> getArray() {
             return null; // todo implement getValues
         }
 



Mime
View raw message