jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1305303 - 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 10:48:18 GMT
Author: mduerig
Date: Mon Mar 26 10:48:18 2012
New Revision: 1305303

URL: http://svn.apache.org/viewvc?rev=1305303&view=rev
Log:
OAK-33: Values in oak-core
- add accessors returning Scalar to PropertyState
- avoid casting to implementation but use above accessors instead

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=1305303&r1=1305302&r2=1305303&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 10:48:18 2012
@@ -67,14 +67,17 @@ public class KernelPropertyState extends
         }
     }
 
+    @Override
     public boolean isMultiValued() {
         return value == null;
     }
     
+    @Override
     public Scalar getValue() {
         return value;
     }
     
+    @Override
     public List<Scalar> getValues() {
         return values;
     }

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=1305303&r1=1305302&r2=1305303&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 10:48:18 2012
@@ -21,7 +21,6 @@ import org.apache.jackrabbit.oak.jcr.sta
 import org.apache.jackrabbit.oak.jcr.util.LogUtil;
 import org.apache.jackrabbit.oak.jcr.util.Path;
 import org.apache.jackrabbit.oak.jcr.util.ValueConverter;
-import org.apache.jackrabbit.oak.kernel.KernelPropertyState;
 import org.apache.jackrabbit.value.ValueHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -358,7 +357,7 @@ public class PropertyImpl extends ItemIm
             throw new ValueFormatException(LogUtil.safeGetJCRPath(this) + " is multi-valued.");
         }
 
-        return ValueConverter.toValue(getValueFactory(), ((KernelPropertyState) state).getValue());
 // fixme don't cast
+        return ValueConverter.toValue(getValueFactory(), state.getValue());
     }
 
     @Override
@@ -368,7 +367,7 @@ public class PropertyImpl extends ItemIm
             throw new ValueFormatException(LogUtil.safeGetJCRPath(this) + " is not multi-valued.");
         }
 
-        return ValueConverter.toValues(getValueFactory(), ((KernelPropertyState) state).getValues());
// fixme don't cast
+        return ValueConverter.toValues(getValueFactory(), state.getValues());
     }
 
     /**
@@ -543,7 +542,7 @@ public class PropertyImpl extends ItemIm
      */
     @Override
     public boolean isMultiple() throws RepositoryException {
-        return ((KernelPropertyState) state).isMultiValued();  // fixme don't cast
+        return state.isMultiValued();
     }
 
     //------------------------------------------------------------< 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=1305303&r1=1305302&r2=1305303&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 10:48:18 2012
@@ -262,7 +262,7 @@ public class ChangeTree {
                     new Predicate<PropertyState>() {
                         @Override
                         public boolean evaluate(PropertyState state) {
-                            return !((KernelPropertyState) state).getValue().equals(ScalarImpl.nullScalar());
 // fixme don't cast
+                            return !state.getValue().equals(ScalarImpl.nullScalar());
                         }
                     });
         }
@@ -345,7 +345,7 @@ public class ChangeTree {
          * @param name
          */
         public void removeProperty(String name)  {
-            KernelPropertyState state = (KernelPropertyState) properties.get(name);  // fixme
don't cast
+            PropertyState state = properties.get(name);
             if (state != null && !state.isMultiValued() && !state.getValue().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=1305303&r1=1305302&r2=1305303&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 10:48:18 2012
@@ -264,7 +264,7 @@ public class TransientNodeState {
      * @return {@code true} iff the property named {@code name} has been transiently added.
      */
     public boolean isPropertyNew(String name) {
-        KernelPropertyState state = (KernelPropertyState) getNodeDelta().getPropertyState(name);
 // fixme don't cast
+        PropertyState state = getNodeDelta().getPropertyState(name);
         if (state == null) {
             return false;
         }
@@ -302,7 +302,7 @@ public class TransientNodeState {
     }
 
     private PropertyState getPropertyStateOrNull(String name) {
-        KernelPropertyState state = (KernelPropertyState) getNodeDelta().getPropertyState(name);
 // fixme don't cast
+        PropertyState state = getNodeDelta().getPropertyState(name);
         if (state == null) {
             return getPersistedPropertyState(name);
         }

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=1305303&r1=1305302&r2=1305303&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 10:48:18 2012
@@ -28,6 +28,7 @@ import javax.jcr.UnsupportedRepositoryOp
 import javax.jcr.Value;
 import javax.jcr.ValueFactory;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
 
 /**
@@ -93,7 +94,7 @@ public final class ValueConverter {
         }
     }
 
-    public static Value[] toValues(ValueFactory valueFactory, List<Scalar> scalars)
+    public static Value[] toValues(ValueFactory valueFactory, Collection<Scalar> scalars)
             throws UnsupportedRepositoryOperationException {
 
         Value[] values = new Value[scalars.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=1305303&r1=1305302&r2=1305303&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 10:48:18 2012
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.mk.model;
 
+import java.util.Collection;
+
 /**
  * Immutable property state. A property consists of a name and
  * a JSON-encoded value.
@@ -41,4 +43,21 @@ public interface PropertyState {
      */
     String getEncodedValue();
 
+    /**
+     * Determine whether this is a multi valued property
+     * @return  {@code true} if and only if this is a multi valued property.
+     */
+    boolean isMultiValued();
+
+    /**
+     * @return  the single value of this property or {@code null} if this is a multi
+     * valued property.
+     */
+    Scalar getValue();
+
+    /**
+     * @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();
 }

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=1305303&r1=1305302&r2=1305303&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 10:48:18 2012
@@ -16,10 +16,6 @@
  */
 package org.apache.jackrabbit.mk.store;
 
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.Map;
-
 import org.apache.jackrabbit.mk.model.AbstractChildNodeEntry;
 import org.apache.jackrabbit.mk.model.AbstractNodeState;
 import org.apache.jackrabbit.mk.model.AbstractPropertyState;
@@ -28,8 +24,14 @@ import org.apache.jackrabbit.mk.model.Ch
 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.StoredNode;
 
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Map;
+
 class StoredNodeAsState extends AbstractNodeState {
 
     private final StoredNode node;
@@ -66,6 +68,21 @@ class StoredNodeAsState extends Abstract
             return value;
         }
 
+        @Override
+        public boolean isMultiValued() {
+            return false; // todo implement isMultiValued
+        }
+
+        @Override
+        public Scalar getValue() {
+            return null; // todo implement getValue
+        }
+
+        @Override
+        public Collection<Scalar> getValues() {
+            return null; // todo implement getValues
+        }
+
     }
 
     @Override



Mime
View raw message