jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1394472 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/api/ oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/ oak-core/src/main/jav...
Date Fri, 05 Oct 2012 12:07:53 GMT
Author: mduerig
Date: Fri Oct  5 12:07:52 2012
New Revision: 1394472

URL: http://svn.apache.org/viewvc?rev=1394472&view=rev
Log:
OAK-350: Unify PropertyState and CoreValue
- Replace PropertyState.getValue() with CoreValues.getValue(PropertyState)
- remove deprecated methods from PropertyState

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/CoreValues.java
  (with props)
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/PropertyState.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/BinaryValue.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneEditor.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexDiff.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexLookup.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexUpdate.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/EmptyPropertyState.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryValue.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MultiPropertyState.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/SinglePropertyState.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/TypeValidator.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/Query.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/ComparisonImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/EquiJoinConditionImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PropertyValueImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/MembershipProviderImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/PropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/PropertyState.java?rev=1394472&r1=1394471&r2=1394472&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/PropertyState.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/PropertyState.java
Fri Oct  5 12:07:52 2012
@@ -16,8 +16,6 @@
  */
 package org.apache.jackrabbit.oak.api;
 
-import java.util.List;
-
 import javax.annotation.Nonnull;
 
 /**
@@ -60,27 +58,6 @@ public interface PropertyState {
     boolean isArray();
 
     /**
-     * Value of this property.
-     * @return  the single value of this property.
-     * @throws IllegalStateException  if {@code isArray()} is {@code true}.
-     */
-    @Nonnull
-    @Deprecated
-    CoreValue getValue();
-
-    /**
-     * Values of this property. The returned list is immutable and contains
-     * all the values of this property. If this is a single-valued property,
-     * then the returned list will simply contain the single value returned
-     * by the {@link #getValue()} method.
-     *
-     * @return immutable list of the values of this property
-     */
-    @Nonnull
-    @Deprecated
-    List<CoreValue> getValues();
-
-    /**
      * Determine the type of this property
      * @return  the type of this property
      */

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/BinaryValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/BinaryValue.java?rev=1394472&r1=1394471&r2=1394472&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/BinaryValue.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/BinaryValue.java
Fri Oct  5 12:07:52 2012
@@ -16,14 +16,14 @@
  */
 package org.apache.jackrabbit.oak.kernel;
 
-import org.apache.jackrabbit.mk.api.MicroKernel;
-import org.apache.jackrabbit.mk.util.MicroKernelInputStream;
-import org.apache.jackrabbit.oak.plugins.memory.MemoryValue;
-
 import java.io.InputStream;
 
 import javax.jcr.PropertyType;
 
+import org.apache.jackrabbit.mk.api.MicroKernel;
+import org.apache.jackrabbit.mk.util.MicroKernelInputStream;
+import org.apache.jackrabbit.oak.plugins.memory.MemoryValue;
+
 /**
  * BinaryValue... TODO: review name (BlobValue? BlobCoreValue? BinaryCoreValue?)
  */
@@ -81,7 +81,7 @@ class BinaryValue extends MemoryValue {
             return binaryID.equals(other.binaryID);
         }
 
-        return false;
+        return super.equals(o);
     }
 
 }
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneEditor.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneEditor.java?rev=1394472&r1=1394471&r2=1394472&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneEditor.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneEditor.java
Fri Oct  5 12:07:52 2012
@@ -24,6 +24,7 @@ import org.apache.jackrabbit.oak.api.Com
 import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.plugins.index.IndexDefinition;
+import org.apache.jackrabbit.oak.plugins.memory.CoreValues;
 import org.apache.jackrabbit.oak.spi.commit.CommitHook;
 import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
@@ -220,7 +221,7 @@ class LuceneEditor implements CommitHook
             document.add(newPathField(path));
             for (PropertyState property : state.getProperties()) {
                 String pname = property.getName();
-                for (CoreValue value : property.getValues()) {
+                for (CoreValue value : CoreValues.getValues(property)) {
                     document.add(newPropertyField(pname,
                             parseStringValue(value)));
                 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexDiff.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexDiff.java?rev=1394472&r1=1394471&r2=1394472&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexDiff.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexDiff.java
Fri Oct  5 12:07:52 2012
@@ -19,16 +19,16 @@ package org.apache.jackrabbit.oak.plugin
 import java.util.List;
 import java.util.Map;
 
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
 import org.apache.jackrabbit.oak.api.PropertyState;
+import org.apache.jackrabbit.oak.plugins.memory.CoreValues;
 import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeStateDiff;
 import org.apache.jackrabbit.oak.spi.state.NodeStateUtils;
 
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-
 class PropertyIndexDiff implements NodeStateDiff {
 
     private final PropertyIndexDiff parent;
@@ -109,22 +109,22 @@ class PropertyIndexDiff implements NodeS
     @Override
     public void propertyAdded(PropertyState after) {
         for (PropertyIndexUpdate update : getIndexes(after.getName())) {
-            update.insert(getPath(), after.getValues());
+            update.insert(getPath(), CoreValues.getValues(after));
         }
     }
 
     @Override
     public void propertyChanged(PropertyState before, PropertyState after) {
         for (PropertyIndexUpdate update : getIndexes(after.getName())) {
-            update.remove(getPath(), before.getValues());
-            update.insert(getPath(), after.getValues());
+            update.remove(getPath(), CoreValues.getValues(before));
+            update.insert(getPath(), CoreValues.getValues(after));
         }
     }
 
     @Override
     public void propertyDeleted(PropertyState before) {
         for (PropertyIndexUpdate update : getIndexes(before.getName())) {
-            update.remove(getPath(), before.getValues());
+            update.remove(getPath(), CoreValues.getValues(before));
         }
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexLookup.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexLookup.java?rev=1394472&r1=1394471&r2=1394472&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexLookup.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexLookup.java
Fri Oct  5 12:07:52 2012
@@ -21,6 +21,7 @@ import java.util.Set;
 import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Type;
+import org.apache.jackrabbit.oak.plugins.memory.CoreValues;
 import org.apache.jackrabbit.oak.plugins.memory.StringValue;
 import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
@@ -92,7 +93,7 @@ public class PropertyIndexLookup {
             // No index available, so first check this node for a match
             property = root.getProperty(name);
             if (property != null) {
-                for (CoreValue cv : property.getValues()) {
+                for (CoreValue cv : CoreValues.getValues(property)) {
                     if (cv.equals(value)) {
                         paths.add("");
                         break;

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexUpdate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexUpdate.java?rev=1394472&r1=1394471&r2=1394472&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexUpdate.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexUpdate.java
Fri Oct  5 12:07:52 2012
@@ -25,6 +25,7 @@ import javax.jcr.PropertyType;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.api.PropertyState;
+import org.apache.jackrabbit.oak.plugins.memory.CoreValues;
 import org.apache.jackrabbit.oak.plugins.memory.MultiPropertyState;
 import org.apache.jackrabbit.oak.plugins.memory.StringValue;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
@@ -88,7 +89,7 @@ class PropertyIndexUpdate {
             PropertyState property = index.getProperty(encoded);
             if (property != null) {
                 List<CoreValue> values = Lists.newArrayList();
-                for (CoreValue value : property.getValues()) {
+                for (CoreValue value : CoreValues.getValues(property)) {
                     if (!paths.contains(value.getString())) {
                         values.add(value);
                     }
@@ -107,7 +108,7 @@ class PropertyIndexUpdate {
             List<CoreValue> values = Lists.newArrayList();
             PropertyState property = index.getProperty(encoded);
             if (property != null) {
-                for (CoreValue value : property.getValues()) {
+                for (CoreValue value : CoreValues.getValues(property)) {
                     values.add(value);
                     paths.remove(value.getString());
                 }

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/CoreValues.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/CoreValues.java?rev=1394472&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/CoreValues.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/CoreValues.java
Fri Oct  5 12:07:52 2012
@@ -0,0 +1,122 @@
+package org.apache.jackrabbit.oak.plugins.memory;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.math.BigDecimal;
+import java.util.List;
+
+import javax.annotation.Nonnull;
+import javax.jcr.PropertyType;
+
+import com.google.common.collect.Lists;
+import com.google.common.io.ByteStreams;
+import org.apache.jackrabbit.oak.api.Blob;
+import org.apache.jackrabbit.oak.api.CoreValue;
+import org.apache.jackrabbit.oak.api.PropertyState;
+
+import static org.apache.jackrabbit.oak.api.Type.BINARIES;
+import static org.apache.jackrabbit.oak.api.Type.BINARY;
+import static org.apache.jackrabbit.oak.api.Type.BOOLEAN;
+import static org.apache.jackrabbit.oak.api.Type.BOOLEANS;
+import static org.apache.jackrabbit.oak.api.Type.DECIMAL;
+import static org.apache.jackrabbit.oak.api.Type.DECIMALS;
+import static org.apache.jackrabbit.oak.api.Type.DOUBLE;
+import static org.apache.jackrabbit.oak.api.Type.DOUBLES;
+import static org.apache.jackrabbit.oak.api.Type.LONG;
+import static org.apache.jackrabbit.oak.api.Type.LONGS;
+import static org.apache.jackrabbit.oak.api.Type.STRING;
+import static org.apache.jackrabbit.oak.api.Type.STRINGS;
+
+/**
+ * The methods of this class adapt a {@code PropertyState} to a {@code CoreValue}.
+ * TODO this is a temporary solution while resolving OAK-350
+ */
+public class CoreValues {
+    private CoreValues() {}
+
+    /**
+     * Value of the {@code property}
+     * @param property
+     * @return The single value of {@code property}.
+     * @throws IllegalStateException if {@code property.isArray()} is {@code true}.
+     */
+    @Nonnull
+    public static CoreValue getValue(PropertyState property) {
+        if (property.isArray()) {
+            throw new IllegalStateException("Not a single valued property");
+        }
+
+        int type = property.getType().tag();
+        switch (type) {
+            case PropertyType.STRING: return new StringValue(property.getValue(STRING));
+            case PropertyType.LONG: return new LongValue(property.getValue(LONG));
+            case PropertyType.DOUBLE: return new DoubleValue(property.getValue(DOUBLE));
+            case PropertyType.BOOLEAN: return property.getValue(BOOLEAN) ? BooleanValue.TRUE
: BooleanValue.FALSE;
+            case PropertyType.DECIMAL: return new DecimalValue(property.getValue(DECIMAL));
+            case PropertyType.BINARY: return binaryValue(property.getValue(BINARY));
+            default: return new GenericValue(type, property.getValue(STRING));
+        }
+    }
+
+    /**
+     * Values of  {@code property}. The returned list is immutable and contains
+     * all the values of the property. If {@code property} is a single-valued property,
+     * then the returned list will simply contain a single value.
+     * @param property
+     * @return immutable list of the values of this property
+     */
+    @Nonnull
+    public static List<CoreValue> getValues(PropertyState property) {
+        List<CoreValue> cvs = Lists.newArrayList();
+        int type = property.getType().tag();
+        switch (type) {
+            case PropertyType.STRING:
+                for (String value : property.getValue(STRINGS)) {
+                    cvs.add(new StringValue(value));
+                }
+                break;
+            case PropertyType.LONG:
+                for (long value : property.getValue(LONGS)) {
+                    cvs.add(new LongValue(value));
+                }
+                break;
+            case PropertyType.DOUBLE:
+                for (double value : property.getValue(DOUBLES)) {
+                    cvs.add(new DoubleValue(value));
+                }
+                break;
+            case PropertyType.BOOLEAN:
+                for (boolean value : property.getValue(BOOLEANS)) {
+                    cvs.add(value ? BooleanValue.TRUE : BooleanValue.FALSE);
+                }
+                break;
+            case PropertyType.DECIMAL:
+                for (BigDecimal value : property.getValue(DECIMALS)) {
+                    cvs.add(new DecimalValue(value));
+                }
+                break;
+            case PropertyType.BINARY:
+                for (Blob value : property.getValue(BINARIES)) {
+                    cvs.add(binaryValue(value));
+                }
+                break;
+            default:
+                for (String value : property.getValue(STRINGS)) {
+                    cvs.add(new GenericValue(type, value));
+                }
+        }
+        return cvs;
+    }
+
+    private static CoreValue binaryValue(Blob blob) {
+        InputStream in = blob.getNewStream();
+        try {
+            return new BinaryValue(ByteStreams.toByteArray(in));
+        }
+        catch (IOException e) {
+            // TODO better return a stream which defers this exception until accessed
+            throw new IllegalStateException(e);
+        }
+    }
+
+}

Propchange: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/CoreValues.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/CoreValues.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/EmptyPropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/EmptyPropertyState.java?rev=1394472&r1=1394471&r2=1394472&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/EmptyPropertyState.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/EmptyPropertyState.java
Fri Oct  5 12:07:52 2012
@@ -19,9 +19,6 @@
 package org.apache.jackrabbit.oak.plugins.memory;
 
 import java.util.Collections;
-import java.util.List;
-
-import javax.annotation.Nonnull;
 
 import org.apache.jackrabbit.oak.api.Blob;
 import org.apache.jackrabbit.oak.api.CoreValue;
@@ -59,20 +56,6 @@ class EmptyPropertyState implements Prop
     }
 
     @Override
-    @Nonnull
-    @Deprecated
-    public CoreValue getValue() {
-        throw new IllegalStateException("Not a single valued property");
-    }
-
-    @Override
-    @Nonnull
-    @Deprecated
-    public List<CoreValue> getValues() {
-        return Collections.emptyList();
-    }
-
-    @Override
     public Type<?> getType() {
         return type;
     }
@@ -127,7 +110,7 @@ class EmptyPropertyState implements Prop
             PropertyState other = (PropertyState) that;
             return getName().equals(other.getName())
                     && isArray() == other.isArray()
-                    && getValues().equals(other.getValues());
+                    && CoreValues.getValues(this).equals(CoreValues.getValues(other));
         } else {
             return false;
         }
@@ -149,7 +132,7 @@ class EmptyPropertyState implements Prop
 
     @Override
     public String toString() {
-        return getName() + '=' + getValues();
+        return getName() + '=' + CoreValues.getValues(this);
     }
 
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryValue.java?rev=1394472&r1=1394471&r2=1394472&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryValue.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryValue.java
Fri Oct  5 12:07:52 2012
@@ -17,17 +17,23 @@
 package org.apache.jackrabbit.oak.plugins.memory;
 
 import java.io.ByteArrayInputStream;
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
 import java.math.BigDecimal;
+import java.util.Arrays;
 import java.util.Calendar;
 
 import javax.jcr.PropertyType;
 
+import com.google.common.io.ByteStreams;
 import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.util.ISO8601;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public abstract class MemoryValue implements CoreValue {
+    private static final Logger log = LoggerFactory.getLogger(MemoryValue.class);
 
     @Override
     public long getLong() {
@@ -90,11 +96,40 @@ public abstract class MemoryValue implem
             } else {
                 return getString().compareTo(o.getString());
             }
+        } else if (type == PropertyType.BINARY) {
+            return compare(getNewStream(), o.getNewStream()) ? 0 : 1;
         } else {
             return getString().compareTo(o.getString());
         }
     }
 
+    private static boolean compare(InputStream in2, InputStream in1) {
+        try {
+            try {
+                byte[] buf1 = new byte[0x1000];
+                byte[] buf2 = new byte[0x1000];
+
+                while (true) {
+                    int read1 = ByteStreams.read(in1, buf1, 0, 0x1000);
+                    int read2 = ByteStreams.read(in2, buf2, 0, 0x1000);
+                    if (read1 != read2 || !Arrays.equals(buf1, buf2)) {
+                        return false;
+                    } else if (read1 != 0x1000) {
+                        return true;
+                    }
+                }
+            }
+            finally {
+                in1.close();
+                in2.close();
+            }
+        }
+        catch (IOException e) {
+            log.warn("Error comparing binary values", e);
+            return false;
+        }
+    }
+
     //--------------------------------------------------------------< Object >
 
     @Override

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MultiPropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MultiPropertyState.java?rev=1394472&r1=1394471&r2=1394472&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MultiPropertyState.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MultiPropertyState.java
Fri Oct  5 12:07:52 2012
@@ -23,7 +23,6 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
-import javax.annotation.Nonnull;
 import javax.jcr.PropertyType;
 
 import org.apache.jackrabbit.oak.api.Blob;
@@ -31,7 +30,7 @@ import org.apache.jackrabbit.oak.api.Cor
 import org.apache.jackrabbit.oak.api.Type;
 
 import static com.google.common.base.Preconditions.checkNotNull;
-import static org.apache.jackrabbit.oak.api.Type.*;
+import static org.apache.jackrabbit.oak.api.Type.STRINGS;
 
 /**
  * Multi-valued property state.
@@ -56,13 +55,6 @@ public class MultiPropertyState extends 
     }
 
     @Override
-    @Nonnull
-    @Deprecated
-    public List<CoreValue> getValues() {
-        return values;
-    }
-
-    @Override
     public long size(int index) {
         return values.get(index).length();
     }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/SinglePropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/SinglePropertyState.java?rev=1394472&r1=1394471&r2=1394472&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/SinglePropertyState.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/SinglePropertyState.java
Fri Oct  5 12:07:52 2012
@@ -19,9 +19,7 @@
 package org.apache.jackrabbit.oak.plugins.memory;
 
 import java.util.Collections;
-import java.util.List;
 
-import javax.annotation.Nonnull;
 import javax.jcr.PropertyType;
 
 import org.apache.jackrabbit.oak.api.CoreValue;
@@ -63,20 +61,6 @@ public class SinglePropertyState extends
         return false;
     }
 
-    @Override
-    @Nonnull
-    @Deprecated
-    public CoreValue getValue() {
-        return value;
-    }
-
-    @Override
-    @Nonnull
-    @Deprecated
-    public List<CoreValue> getValues() {
-        return Collections.singletonList(value);
-    }
-
     @SuppressWarnings("unchecked")
     @Override
     public <T> T getValue(Type<T> type) {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/TypeValidator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/TypeValidator.java?rev=1394472&r1=1394471&r2=1394472&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/TypeValidator.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/TypeValidator.java
Fri Oct  5 12:07:52 2012
@@ -36,6 +36,7 @@ import org.apache.jackrabbit.oak.api.Pro
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.core.ReadOnlyTree;
 import org.apache.jackrabbit.oak.namepath.NamePathMapper;
+import org.apache.jackrabbit.oak.plugins.memory.CoreValues;
 import org.apache.jackrabbit.oak.spi.commit.Validator;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.value.ValueImpl;
@@ -259,10 +260,10 @@ class TypeValidator implements Validator
                 return;
             }
             if (property.isArray()) {
-                checkSetProperty(property.getName(), property.getValues());
+                checkSetProperty(property.getName(), CoreValues.getValues(property));
             }
             else {
-                checkSetProperty(property.getName(), property.getValue());
+                checkSetProperty(property.getName(), CoreValues.getValue(property));
             }
         }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/Query.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/Query.java?rev=1394472&r1=1394471&r2=1394472&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/Query.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/Query.java
Fri Oct  5 12:07:52 2012
@@ -30,6 +30,7 @@ import org.apache.jackrabbit.oak.api.Pro
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.namepath.NamePathMapper;
+import org.apache.jackrabbit.oak.plugins.memory.CoreValues;
 import org.apache.jackrabbit.oak.query.ast.AstVisitorBase;
 import org.apache.jackrabbit.oak.query.ast.BindVariableValueImpl;
 import org.apache.jackrabbit.oak.query.ast.ChildNodeImpl;
@@ -612,7 +613,7 @@ public class Query {
         for (int i = 0; i < columnCount; i++) {
             ColumnImpl c = columns[i];
             PropertyState p = c.currentProperty();
-            values[i] = p == null ? null : p.getValue();
+            values[i] = p == null ? null : CoreValues.getValue(p);
         }
         CoreValue[][] orderValues;
         if (orderings == null) {
@@ -626,10 +627,10 @@ public class Query {
                 if (p == null) {
                     x = null;
                 } else if (p.isArray()) {
-                    List<CoreValue> list = p.getValues();
+                    List<CoreValue> list = CoreValues.getValues(p);
                     x = list.toArray(new CoreValue[list.size()]);
                 } else {
-                    x = new CoreValue[] { p.getValue() };
+                    x = new CoreValue[] { CoreValues.getValue(p) };
                 }
                 orderValues[i] = x;
             }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/ComparisonImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/ComparisonImpl.java?rev=1394472&r1=1394471&r2=1394472&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/ComparisonImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/ComparisonImpl.java
Fri Oct  5 12:07:52 2012
@@ -20,6 +20,7 @@ package org.apache.jackrabbit.oak.query.
 
 import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.api.PropertyState;
+import org.apache.jackrabbit.oak.plugins.memory.CoreValues;
 import org.apache.jackrabbit.oak.query.Query;
 import org.apache.jackrabbit.oak.query.index.FilterImpl;
 
@@ -76,11 +77,11 @@ public class ComparisonImpl extends Cons
             }
         }
         if (!isArray) {
-            return evaluate(p1.getValue(), v2);
+            return evaluate(CoreValues.getValue(p1), v2);
         }
         // for multi-valued properties: if any of the value matches,
         // then return true
-        for (CoreValue v1 : p1.getValues()) {
+        for (CoreValue v1 : CoreValues.getValues(p1)) {
             if (evaluate(v1, v2)) {
                 return true;
             }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/EquiJoinConditionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/EquiJoinConditionImpl.java?rev=1394472&r1=1394471&r2=1394472&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/EquiJoinConditionImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/EquiJoinConditionImpl.java
Fri Oct  5 12:07:52 2012
@@ -20,6 +20,7 @@ package org.apache.jackrabbit.oak.query.
 
 import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.api.PropertyState;
+import org.apache.jackrabbit.oak.plugins.memory.CoreValues;
 import org.apache.jackrabbit.oak.query.Query;
 import org.apache.jackrabbit.oak.query.index.FilterImpl;
 
@@ -71,12 +72,12 @@ public class EquiJoinConditionImpl exten
         }
         if (!p1.isArray() && !p2.isArray()) {
             // both are single valued
-            return p1.getValue().equals(p2.getValue());
+            return CoreValues.getValue(p1).equals(CoreValues.getValue(p2));
         }
         // TODO what is the expected result of an equi join for multi-valued properties?
         if (!p1.isArray() && p2.isArray()) {
-            CoreValue x = p1.getValue();
-            for (CoreValue y : p2.getValues()) {
+            CoreValue x = CoreValues.getValue(p1);
+            for (CoreValue y : CoreValues.getValues(p2)) {
                 if (y.getType() != x.getType()) {
                     y = query.convert(y, x.getType());
                 }
@@ -86,8 +87,8 @@ public class EquiJoinConditionImpl exten
             }
             return false;
         } else if (p1.isArray() && !p2.isArray()) {
-            CoreValue x = p2.getValue();
-            for (CoreValue y : p1.getValues()) {
+            CoreValue x = CoreValues.getValue(p2);
+            for (CoreValue y : CoreValues.getValues(p1)) {
                 if (y.getType() != x.getType()) {
                     y = query.convert(y, x.getType());
                 }
@@ -97,8 +98,8 @@ public class EquiJoinConditionImpl exten
             }
             return false;
         }
-        CoreValue[] l1 = p1.getValues().toArray(new CoreValue[p1.getValues().size()]);
-        CoreValue[] l2 = p2.getValues().toArray(new CoreValue[p2.getValues().size()]);
+        CoreValue[] l1 = CoreValues.getValues(p1).toArray(new CoreValue[p1.count()]);
+        CoreValue[] l2 = CoreValues.getValues(p2).toArray(new CoreValue[p2.count()]);
         return Query.compareValues(l1, l2) == 0;
     }
 
@@ -109,13 +110,13 @@ public class EquiJoinConditionImpl exten
         if (f.getSelector() == selector1 && p2 != null) {
             if (!p2.isArray()) {
                 // TODO support join on multi-valued properties
-                f.restrictProperty(property1Name, Operator.EQUAL, p2.getValue());
+                f.restrictProperty(property1Name, Operator.EQUAL, CoreValues.getValue(p2));
             }
         }
         if (f.getSelector() == selector2 && p1 != null) {
             if (!p1.isArray()) {
                 // TODO support join on multi-valued properties
-                f.restrictProperty(property2Name, Operator.EQUAL, p1.getValue());
+                f.restrictProperty(property2Name, Operator.EQUAL, CoreValues.getValue(p1));
             }
         }
     }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PropertyValueImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PropertyValueImpl.java?rev=1394472&r1=1394471&r2=1394472&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PropertyValueImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PropertyValueImpl.java
Fri Oct  5 12:07:52 2012
@@ -27,6 +27,7 @@ import org.apache.jackrabbit.oak.api.Cor
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.commons.PathUtils;
+import org.apache.jackrabbit.oak.plugins.memory.CoreValues;
 import org.apache.jackrabbit.oak.plugins.memory.MultiPropertyState;
 import org.apache.jackrabbit.oak.query.SQL2Parser;
 import org.apache.jackrabbit.oak.query.index.FilterImpl;
@@ -118,9 +119,9 @@ public class PropertyValueImpl extends D
         for (PropertyState p : tree.getProperties()) {
             if (matchesPropertyType(p)) {
                 if (p.isArray()) {
-                    values.addAll(p.getValues());
+                    values.addAll(CoreValues.getValues(p));
                 } else {
-                    values.add(p.getValue());
+                    values.add(CoreValues.getValue(p));
                 }
             }
         }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/MembershipProviderImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/MembershipProviderImpl.java?rev=1394472&r1=1394471&r2=1394472&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/MembershipProviderImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/MembershipProviderImpl.java
Fri Oct  5 12:07:52 2012
@@ -35,6 +35,7 @@ import org.apache.jackrabbit.oak.api.Cor
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.api.Tree;
+import org.apache.jackrabbit.oak.plugins.memory.CoreValues;
 import org.apache.jackrabbit.oak.plugins.memory.MultiPropertyState;
 import org.apache.jackrabbit.oak.spi.security.user.MembershipProvider;
 import org.apache.jackrabbit.oak.spi.security.user.Type;
@@ -145,7 +146,7 @@ public class MembershipProviderImpl exte
         } else {
             PropertyState property = groupTree.getProperty(REP_MEMBERS);
             if (property != null) {
-                List<CoreValue> vs = property.getValues();
+                List<CoreValue> vs = CoreValues.getValues(property);
                 memberPaths = Iterables.transform(vs, new Function<CoreValue,String>()
{
                     @Override
                     public String apply(@Nullable CoreValue value) {
@@ -210,7 +211,7 @@ public class MembershipProviderImpl exte
             CoreValue toAdd = createCoreValue(newMemberTree);
             PropertyState property = groupTree.getProperty(REP_MEMBERS);
             if (property != null) {
-                values = property.getValues();
+                values = CoreValues.getValues(property);
                 if (values.contains(toAdd)) {
                     return false;
                 } else {
@@ -237,7 +238,7 @@ public class MembershipProviderImpl exte
             PropertyState property = groupTree.getProperty(REP_MEMBERS);
             if (property != null) {
                 CoreValue toRemove = createCoreValue(memberTree);
-                List<CoreValue> values = property.getValues();
+                List<CoreValue> values = CoreValues.getValues(property);
                 if (values.remove(toRemove)) {
                     if (values.isEmpty()) {
                         groupTree.removeProperty(REP_MEMBERS);

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java?rev=1394472&r1=1394471&r2=1394472&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java
Fri Oct  5 12:07:52 2012
@@ -29,6 +29,7 @@ import org.apache.jackrabbit.oak.api.Cor
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.TreeLocation;
 import org.apache.jackrabbit.oak.core.TreeImpl.PropertyLocation;
+import org.apache.jackrabbit.oak.plugins.memory.CoreValues;
 import org.apache.jackrabbit.oak.plugins.memory.MultiPropertyState;
 import org.apache.jackrabbit.oak.plugins.memory.SinglePropertyState;
 import org.apache.jackrabbit.oak.util.TODO;
@@ -53,7 +54,7 @@ public class PropertyDelegate extends It
      */
     @Nonnull
     public CoreValue getValue() throws InvalidItemStateException {
-        return getPropertyState().getValue();
+        return CoreValues.getValue(getPropertyState());
     }
 
     /**
@@ -63,7 +64,7 @@ public class PropertyDelegate extends It
      */
     @Nonnull
     public Iterable<CoreValue> getValues() throws InvalidItemStateException {
-        return getPropertyState().getValues();
+        return CoreValues.getValues(getPropertyState());
     }
 
     /**



Mime
View raw message