jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexparvule...@apache.org
Subject svn commit: r1397098 [2/2] - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/api/ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/identifier/ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/ oak...
Date Thu, 11 Oct 2012 14:58:30 GMT
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/LiteralImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/LiteralImpl.java?rev=1397098&r1=1397097&r2=1397098&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/LiteralImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/LiteralImpl.java Thu Oct 11 14:58:28 2012
@@ -19,23 +19,25 @@
 package org.apache.jackrabbit.oak.query.ast;
 
 import java.util.Locale;
-import org.apache.jackrabbit.oak.api.CoreValue;
-import org.apache.jackrabbit.oak.query.SQL2Parser;
 
 import javax.jcr.PropertyType;
 
+import org.apache.jackrabbit.oak.api.Type;
+import org.apache.jackrabbit.oak.query.SQL2Parser;
+import org.apache.jackrabbit.oak.spi.query.PropertyValue;
+
 /**
  * A literal of a certain data type, possibly "cast(..)" of a literal.
  */
 public class LiteralImpl extends StaticOperandImpl {
 
-    private final CoreValue value;
+    private final PropertyValue value;
 
-    public LiteralImpl(CoreValue value) {
+    public LiteralImpl(PropertyValue value) {
         this.value = value;
     }
 
-    public CoreValue getLiteralValue() {
+    public PropertyValue getLiteralValue() {
         return value;
     }
 
@@ -46,16 +48,16 @@ public class LiteralImpl extends StaticO
 
     @Override
     public String toString() {
-        String type = PropertyType.nameFromValue(value.getType());
+        String type = PropertyType.nameFromValue(value.getType().tag());
         return "cast(" + escape() + " as " + type.toLowerCase(Locale.ENGLISH) + ')';
     }
 
     private String escape() {
-        return SQL2Parser.escapeStringLiteral(value.getString());
+        return SQL2Parser.escapeStringLiteral(value.getValue(Type.STRING));
     }
 
     @Override
-    CoreValue currentValue() {
+    PropertyValue currentValue() {
         return value;
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/LowerCaseImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/LowerCaseImpl.java?rev=1397098&r1=1397097&r2=1397098&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/LowerCaseImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/LowerCaseImpl.java Thu Oct 11 14:58:28 2012
@@ -18,12 +18,12 @@
  */
 package org.apache.jackrabbit.oak.query.ast;
 
-import org.apache.jackrabbit.oak.api.CoreValue;
+import static org.apache.jackrabbit.oak.api.Type.STRING;
+
 import org.apache.jackrabbit.oak.api.PropertyState;
-import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
 import org.apache.jackrabbit.oak.query.index.FilterImpl;
-
-import static org.apache.jackrabbit.oak.api.Type.STRING;
+import org.apache.jackrabbit.oak.spi.query.PropertyValue;
+import org.apache.jackrabbit.oak.spi.query.PropertyValues;
 
 /**
  * The function "lower(..)".
@@ -51,7 +51,7 @@ public class LowerCaseImpl extends Dynam
     }
 
     @Override
-    public PropertyState currentProperty() {
+    public PropertyValue currentProperty() {
         PropertyState p = operand.currentProperty();
         if (p == null) {
             return null;
@@ -59,13 +59,13 @@ public class LowerCaseImpl extends Dynam
         // TODO what is the expected result of LOWER(x) for an array property?
         // currently throws an exception
         String value = p.getValue(STRING);
-        return PropertyStates.stringProperty(p.getName(), value.toLowerCase());
+        return PropertyValues.newString(value.toLowerCase());
     }
 
     @Override
-    public void restrict(FilterImpl f, Operator operator, CoreValue v) {
+    public void restrict(FilterImpl f, Operator operator, PropertyValue v) {
         // LOWER(x) implies x is not null
-        operand.restrict(f, Operator.NOT_EQUAL, null);        
+        operand.restrict(f, Operator.NOT_EQUAL, null);
     }
 
     @Override

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/NodeLocalNameImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/NodeLocalNameImpl.java?rev=1397098&r1=1397097&r2=1397098&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/NodeLocalNameImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/NodeLocalNameImpl.java Thu Oct 11 14:58:28 2012
@@ -18,11 +18,10 @@
  */
 package org.apache.jackrabbit.oak.query.ast;
 
-import org.apache.jackrabbit.oak.api.CoreValue;
-import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.commons.PathUtils;
-import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
 import org.apache.jackrabbit.oak.query.index.FilterImpl;
+import org.apache.jackrabbit.oak.spi.query.PropertyValue;
+import org.apache.jackrabbit.oak.spi.query.PropertyValues;
 import org.apache.jackrabbit.util.ISO9075;
 
 /**
@@ -52,18 +51,18 @@ public class NodeLocalNameImpl extends D
     }
 
     @Override
-    public PropertyState currentProperty() {
+    public PropertyValue currentProperty() {
         String name = PathUtils.getName(selector.currentPath());
         // Name escaping (convert space to _x0020_)
         name = ISO9075.encode(name);
         int colon = name.indexOf(':');
         // TODO LOCALNAME: evaluation of local name might not be correct
         String localName = colon < 0 ? name : name.substring(colon + 1);
-        return PropertyStates.stringProperty("LOCALNAME", localName);
+        return PropertyValues.newString(localName);
     }
 
     @Override
-    public void restrict(FilterImpl f, Operator operator, CoreValue v) {
+    public void restrict(FilterImpl f, Operator operator, PropertyValue v) {
         // TODO support LOCALNAME index conditions
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/NodeNameImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/NodeNameImpl.java?rev=1397098&r1=1397097&r2=1397098&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/NodeNameImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/NodeNameImpl.java Thu Oct 11 14:58:28 2012
@@ -20,11 +20,11 @@ package org.apache.jackrabbit.oak.query.
 
 import javax.jcr.PropertyType;
 
-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.commons.PathUtils;
-import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
 import org.apache.jackrabbit.oak.query.index.FilterImpl;
+import org.apache.jackrabbit.oak.spi.query.PropertyValue;
+import org.apache.jackrabbit.oak.spi.query.PropertyValues;
 import org.apache.jackrabbit.util.ISO9075;
 
 /**
@@ -59,22 +59,22 @@ public class NodeNameImpl extends Dynami
     }
 
     @Override
-    public PropertyState currentProperty() {
+    public PropertyValue currentProperty() {
         String path = selector.currentPath();
         // Name escaping (convert space to _x0020_)
         String name = ISO9075.encode(PathUtils.getName(path));
-        return PropertyStates.nameProperty("NAME", name);
+        return PropertyValues.newName(name);
     }
 
     @Override
-    public void restrict(FilterImpl f, Operator operator, CoreValue v) {
+    public void restrict(FilterImpl f, Operator operator, PropertyValue v) {
         if (v == null) {
             return;
         }
         if (!isName(v)) {
             throw new IllegalArgumentException("Invalid name value: " + v.toString());
         }
-        String path = v.getString();
+        String path = v.getValue(Type.STRING);
         // Name escaping (convert _x0020_ to space)
         path = decodeName(path);
         if (PathUtils.isAbsolute(path)) {
@@ -95,7 +95,7 @@ public class NodeNameImpl extends Dynami
         // Name escaping (convert _x0020_ to space)
         path = ISO9075.decode(path);
         // normalize paths (./name > name)
-        path = query.getOakPath(path);
+        path = PropertyValues.getOakPath(path, query.getNamePathMapper());
         return path;
     }
 
@@ -105,9 +105,9 @@ public class NodeNameImpl extends Dynami
      * @param v the value
      * @return true if it can be converted
      */
-    private static boolean isName(CoreValue v) {
+    private static boolean isName(PropertyValue v) {
         // TODO correctly validate JCR names - see JCR 2.0 spec 3.2.4 Naming Restrictions
-        switch (v.getType()) {
+        switch (v.getType().tag()) {
         case PropertyType.DATE:
         case PropertyType.DECIMAL:
         case PropertyType.DOUBLE:
@@ -115,7 +115,7 @@ public class NodeNameImpl extends Dynami
         case PropertyType.BOOLEAN:
             return false;
         }
-        String n = v.getString();
+        String n = v.getValue(Type.STRING);
         if (n.startsWith("[") && !n.endsWith("]")) {
             return false;
         }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PropertyExistenceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PropertyExistenceImpl.java?rev=1397098&r1=1397097&r2=1397098&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PropertyExistenceImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PropertyExistenceImpl.java Thu Oct 11 14:58:28 2012
@@ -18,8 +18,6 @@
  */
 package org.apache.jackrabbit.oak.query.ast;
 
-import org.apache.jackrabbit.oak.api.CoreValue;
-import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.query.index.FilterImpl;
 
 /**
@@ -38,8 +36,7 @@ public class PropertyExistenceImpl exten
 
     @Override
     public boolean evaluate() {
-        PropertyState p = selector.currentProperty(propertyName);
-        return p != null;
+        return selector.currentProperty(propertyName) != null;
     }
 
     @Override
@@ -59,7 +56,7 @@ public class PropertyExistenceImpl exten
     @Override
     public void restrict(FilterImpl f) {
         if (f.getSelector() == selector) {
-            f.restrictProperty(propertyName, Operator.NOT_EQUAL, (CoreValue) null);
+            f.restrictProperty(propertyName, Operator.NOT_EQUAL, null);
         }
     }
 

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=1397098&r1=1397097&r2=1397098&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 Thu Oct 11 14:58:28 2012
@@ -24,15 +24,16 @@ import java.util.Locale;
 
 import javax.jcr.PropertyType;
 
-import com.google.common.collect.Iterables;
-import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.commons.PathUtils;
-import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
 import org.apache.jackrabbit.oak.query.SQL2Parser;
 import org.apache.jackrabbit.oak.query.index.FilterImpl;
+import org.apache.jackrabbit.oak.spi.query.PropertyValue;
+import org.apache.jackrabbit.oak.spi.query.PropertyValues;
+
+import com.google.common.collect.Iterables;
 
 /**
  * A property expression.
@@ -81,11 +82,11 @@ public class PropertyValueImpl extends D
     }
 
     @Override
-    public PropertyState currentProperty() {
+    public PropertyValue currentProperty() {
         boolean relative = propertyName.indexOf('/') >= 0;
         boolean asterisk = propertyName.equals("*");
         if (!relative && !asterisk) {
-            PropertyState p = selector.currentProperty(propertyName);
+            PropertyValue p = selector.currentProperty(propertyName);
             return matchesPropertyType(p) ? p : null;
         }
         Tree tree = getTree(selector.currentPath());
@@ -112,7 +113,7 @@ public class PropertyValueImpl extends D
                 return null;
             }
             PropertyState p = tree.getProperty(name);
-            return matchesPropertyType(p) ? p : null;
+            return matchesPropertyType(p) ? PropertyValues.create(p) : null;
         }
         // asterisk - create a multi-value property
         // warning: the returned property state may have a mixed type
@@ -125,7 +126,8 @@ public class PropertyValueImpl extends D
                 Iterables.addAll(values, p.getValue(Type.STRINGS));
             }
         }
-        return PropertyStates.stringProperty("*", values);
+        // "*"
+        return PropertyValues.newString(values);
     }
 
     private boolean matchesPropertyType(PropertyState state) {
@@ -143,7 +145,7 @@ public class PropertyValueImpl extends D
     }
 
     @Override
-    public void restrict(FilterImpl f, Operator operator, CoreValue v) {
+    public void restrict(FilterImpl f, Operator operator, PropertyValue v) {
         if (f.getSelector() == selector) {
             if (operator == Operator.NOT_EQUAL && v != null) {
                 // not supported

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java?rev=1397098&r1=1397097&r2=1397098&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java Thu Oct 11 14:58:28 2012
@@ -18,6 +18,8 @@
  */
 package org.apache.jackrabbit.oak.query.ast;
 
+import static org.apache.jackrabbit.oak.api.Type.STRINGS;
+
 import java.util.Set;
 
 import javax.annotation.CheckForNull;
@@ -26,10 +28,8 @@ import javax.jcr.nodetype.NodeType;
 import javax.jcr.nodetype.NodeTypeIterator;
 import javax.jcr.nodetype.NodeTypeManager;
 
-import com.google.common.collect.ImmutableSet;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Tree;
-import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
 import org.apache.jackrabbit.oak.plugins.nodetype.NodeTypeConstants;
 import org.apache.jackrabbit.oak.plugins.nodetype.ReadOnlyNodeTypeManager;
 import org.apache.jackrabbit.oak.query.Query;
@@ -37,10 +37,12 @@ import org.apache.jackrabbit.oak.query.i
 import org.apache.jackrabbit.oak.spi.query.Cursor;
 import org.apache.jackrabbit.oak.spi.query.Filter;
 import org.apache.jackrabbit.oak.spi.query.IndexRow;
+import org.apache.jackrabbit.oak.spi.query.PropertyValue;
+import org.apache.jackrabbit.oak.spi.query.PropertyValues;
 import org.apache.jackrabbit.oak.spi.query.QueryIndex;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 
-import static org.apache.jackrabbit.oak.api.Type.STRINGS;
+import com.google.common.collect.ImmutableSet;
 
 /**
  * A selector within a query.
@@ -216,7 +218,7 @@ public class SelectorImpl extends Source
         return cursor == null ? null : cursor.currentRow().getPath();
     }
 
-    public PropertyState currentProperty(String propertyName) {
+    public PropertyValue currentProperty(String propertyName) {
         if (propertyName.equals(Query.JCR_PATH)) {
             String p = currentPath();
             if (p == null) {
@@ -227,7 +229,7 @@ public class SelectorImpl extends Source
                 // not a local path
                 return null;
             }
-            return PropertyStates.stringProperty(Query.JCR_PATH, local);
+            return PropertyValues.newString(local);
         }
         if (cursor == null) {
             return null;
@@ -243,7 +245,7 @@ public class SelectorImpl extends Source
             return null;
         }
         Tree t = getTree(path);
-        return t == null ? null : t.getProperty(propertyName);
+        return t == null ? null : PropertyValues.create(t.getProperty(propertyName));
     }
 
     @Override

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/StaticOperandImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/StaticOperandImpl.java?rev=1397098&r1=1397097&r2=1397098&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/StaticOperandImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/StaticOperandImpl.java Thu Oct 11 14:58:28 2012
@@ -18,13 +18,13 @@
  */
 package org.apache.jackrabbit.oak.query.ast;
 
-import org.apache.jackrabbit.oak.api.CoreValue;
+import org.apache.jackrabbit.oak.spi.query.PropertyValue;
 
 /**
  * The base class for static operands (literal, bind variables).
  */
 public abstract class StaticOperandImpl extends AstElement {
 
-    abstract CoreValue currentValue();
+    abstract PropertyValue currentValue();
 
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/UpperCaseImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/UpperCaseImpl.java?rev=1397098&r1=1397097&r2=1397098&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/UpperCaseImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/UpperCaseImpl.java Thu Oct 11 14:58:28 2012
@@ -18,12 +18,12 @@
  */
 package org.apache.jackrabbit.oak.query.ast;
 
-import org.apache.jackrabbit.oak.api.CoreValue;
+import static org.apache.jackrabbit.oak.api.Type.STRING;
+
 import org.apache.jackrabbit.oak.api.PropertyState;
-import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
 import org.apache.jackrabbit.oak.query.index.FilterImpl;
-
-import static org.apache.jackrabbit.oak.api.Type.STRING;
+import org.apache.jackrabbit.oak.spi.query.PropertyValue;
+import org.apache.jackrabbit.oak.spi.query.PropertyValues;
 
 /**
  * The function "upper(..)".
@@ -51,7 +51,7 @@ public class UpperCaseImpl extends Dynam
     }
 
     @Override
-    public PropertyState currentProperty() {
+    public PropertyValue currentProperty() {
         PropertyState p = operand.currentProperty();
         if (p == null) {
             return null;
@@ -59,11 +59,11 @@ public class UpperCaseImpl extends Dynam
         // TODO what is the expected result of UPPER(x) for an array property?
         // currently throws an exception
         String value = p.getValue(STRING);
-        return PropertyStates.stringProperty(p.getName(), value.toUpperCase());
+        return PropertyValues.newString(value.toUpperCase());
     }
 
     @Override
-    public void restrict(FilterImpl f, Operator operator, CoreValue v) {
+    public void restrict(FilterImpl f, Operator operator, PropertyValue v) {
         // UPPER(x) implies x is not null
         operand.restrict(f, Operator.NOT_EQUAL, null);
     }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/FilterImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/FilterImpl.java?rev=1397098&r1=1397097&r2=1397098&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/FilterImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/FilterImpl.java Thu Oct 11 14:58:28 2012
@@ -18,19 +18,20 @@
  */
 package org.apache.jackrabbit.oak.query.index;
 
-import org.apache.jackrabbit.oak.commons.PathUtils;
-import org.apache.jackrabbit.oak.api.CoreValue;
-import org.apache.jackrabbit.oak.query.ast.Operator;
-import org.apache.jackrabbit.oak.query.ast.SelectorImpl;
-import org.apache.jackrabbit.oak.spi.query.Filter;
-
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map.Entry;
+
 import javax.jcr.PropertyType;
 
+import org.apache.jackrabbit.oak.commons.PathUtils;
+import org.apache.jackrabbit.oak.query.ast.Operator;
+import org.apache.jackrabbit.oak.query.ast.SelectorImpl;
+import org.apache.jackrabbit.oak.spi.query.Filter;
+import org.apache.jackrabbit.oak.spi.query.PropertyValue;
+
 /**
  * A filter or lookup condition.
  */
@@ -182,46 +183,47 @@ public class FilterImpl implements Filte
         x.propertyType = propertyType;
     }
 
-    public void restrictProperty(String propertyName, Operator op, CoreValue value) {
+    public void restrictProperty(String propertyName, Operator op, PropertyValue v) {
         PropertyRestriction x = propertyRestrictions.get(propertyName);
         if (x == null) {
             x = new PropertyRestriction();
             x.propertyName = propertyName;
             propertyRestrictions.put(propertyName, x);
         }
-        CoreValue oldFirst = x.first, oldLast = x.last;
+        PropertyValue oldFirst = x.first;
+        PropertyValue oldLast = x.last;
         switch (op) {
         case EQUAL:
-            x.first = maxValue(oldFirst, value);
+            x.first = maxValue(oldFirst, v);
             x.firstIncluding = x.first == oldFirst ? x.firstIncluding : true;
-            x.last = minValue(oldLast, value);
+            x.last = minValue(oldLast, v);
             x.lastIncluding = x.last == oldLast ? x.lastIncluding : true;
             break;
         case NOT_EQUAL:
-            if (value != null) {
+            if (v != null) {
                 throw new IllegalArgumentException("NOT_EQUAL only supported for NOT_EQUAL NULL");
             }
             break;
         case GREATER_THAN:
-            x.first = maxValue(oldFirst, value);
+            x.first = maxValue(oldFirst, v);
             x.firstIncluding = false;
             break;
         case GREATER_OR_EQUAL:
-            x.first = maxValue(oldFirst, value);
+            x.first = maxValue(oldFirst, v);
             x.firstIncluding = x.first == oldFirst ? x.firstIncluding : true;
             break;
         case LESS_THAN:
-            x.last = minValue(oldLast, value);
+            x.last = minValue(oldLast, v);
             x.lastIncluding = false;
             break;
         case LESS_OR_EQUAL:
-            x.last = minValue(oldLast, value);
+            x.last = minValue(oldLast, v);
             x.lastIncluding = x.last == oldLast ? x.lastIncluding : true;
             break;
         case LIKE:
             // LIKE is handled in the fulltext index
             x.isLike = true;
-            x.first = value;
+            x.first = v;
             break;
         }
         if (x.first != null && x.last != null) {
@@ -233,18 +235,18 @@ public class FilterImpl implements Filte
         }
     }
 
-    static CoreValue maxValue(CoreValue a, CoreValue b) {
+    static PropertyValue maxValue(PropertyValue a, PropertyValue b) {
         if (a == null) {
             return b;
         }
         return a.compareTo(b) < 0 ? b : a;
     }
 
-    static CoreValue minValue(CoreValue a, CoreValue b) {
+    static PropertyValue minValue(PropertyValue a, PropertyValue b) {
         if (a == null) {
             return b;
         }
-        return a.compareTo(b) < 0 ? a : b;
+        return a.compareTo(b) <= 0 ? a : b;
     }
 
     @Override

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/IndexRowImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/IndexRowImpl.java?rev=1397098&r1=1397097&r2=1397098&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/IndexRowImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/IndexRowImpl.java Thu Oct 11 14:58:28 2012
@@ -18,8 +18,8 @@
  */
 package org.apache.jackrabbit.oak.query.index;
 
-import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.spi.query.IndexRow;
+import org.apache.jackrabbit.oak.spi.query.PropertyValue;
 
 /**
  * A simple index row implementation.
@@ -38,7 +38,7 @@ public class IndexRowImpl implements Ind
     }
 
     @Override
-    public CoreValue getValue(String columnName) {
+    public PropertyValue getValue(String columnName) {
         return null;
     }
 

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=1397098&r1=1397097&r2=1397098&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 Thu Oct 11 14:58:28 2012
@@ -36,6 +36,8 @@ import org.apache.jackrabbit.oak.api.Roo
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.plugins.memory.CoreValues;
 import org.apache.jackrabbit.oak.plugins.memory.MemoryPropertyBuilder;
+import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
+import org.apache.jackrabbit.oak.spi.query.PropertyValues;
 import org.apache.jackrabbit.oak.spi.security.user.AuthorizableType;
 import org.apache.jackrabbit.oak.spi.security.user.MembershipProvider;
 import org.apache.jackrabbit.oak.spi.security.user.UserConfig;
@@ -151,7 +153,7 @@ public class MembershipProviderImpl exte
                 memberPaths = Iterables.transform(vs, new Function<CoreValue,String>() {
                     @Override
                     public String apply(@Nullable CoreValue value) {
-                        return identifierManager.getPath(value);
+                        return identifierManager.getPath(PropertyStates.createProperty("", value.getString(), value.getType()));
                     }
                 });
             }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserProviderImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserProviderImpl.java?rev=1397098&r1=1397097&r2=1397098&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserProviderImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserProviderImpl.java Thu Oct 11 14:58:28 2012
@@ -30,7 +30,6 @@ import javax.jcr.query.Query;
 
 import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.api.security.user.Impersonation;
-import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Result;
 import org.apache.jackrabbit.oak.api.ResultRow;
@@ -38,6 +37,7 @@ import org.apache.jackrabbit.oak.api.Roo
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.namepath.NamePathMapper;
 import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
+import org.apache.jackrabbit.oak.spi.query.PropertyValues;
 import org.apache.jackrabbit.oak.spi.security.principal.PrincipalProvider;
 import org.apache.jackrabbit.oak.spi.security.principal.TreeBasedPrincipal;
 import org.apache.jackrabbit.oak.spi.security.user.AuthorizableType;
@@ -206,14 +206,13 @@ class UserProviderImpl extends Authoriza
         // can be omitted as principals names are stored in user defined
         // index as well.
         try {
-            CoreValue bindValue = valueFactory.createValue(principal.getName());
             StringBuilder stmt = new StringBuilder();
             stmt.append("SELECT * FROM [").append(UserConstants.NT_REP_AUTHORIZABLE).append(']');
             stmt.append("WHERE [").append(UserConstants.REP_PRINCIPAL_NAME).append("] = $principalName");
 
             Result result = root.getQueryEngine().executeQuery(stmt.toString(),
                     Query.JCR_SQL2, 1, 0,
-                    Collections.singletonMap("principalName", bindValue),
+                    Collections.singletonMap("principalName", PropertyValues.newString(principal.getName())),
                     root, new NamePathMapper.Default());
 
             Iterator<? extends ResultRow> rows = result.getRows().iterator();

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/Filter.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/Filter.java?rev=1397098&r1=1397097&r2=1397098&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/Filter.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/Filter.java Thu Oct 11 14:58:28 2012
@@ -21,8 +21,6 @@ package org.apache.jackrabbit.oak.spi.qu
 import java.util.Collection;
 import javax.jcr.PropertyType;
 
-import org.apache.jackrabbit.oak.api.CoreValue;
-
 /**
  * The filter for an index lookup.
  */
@@ -79,7 +77,7 @@ public interface Filter {
         /**
          * The first value to read, or null to read from the beginning.
          */
-        public CoreValue first;
+        public PropertyValue first;
 
         /**
          * Whether values that match the first should be returned.
@@ -89,7 +87,7 @@ public interface Filter {
         /**
          * The last value to read, or null to read until the end.
          */
-        public CoreValue last;
+        public PropertyValue last;
 
         /**
          * Whether values that match the last should be returned.

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/IndexRow.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/IndexRow.java?rev=1397098&r1=1397097&r2=1397098&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/IndexRow.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/IndexRow.java Thu Oct 11 14:58:28 2012
@@ -18,7 +18,6 @@
  */
 package org.apache.jackrabbit.oak.spi.query;
 
-import org.apache.jackrabbit.oak.api.CoreValue;
 
 /**
  * A row returned by the index.
@@ -40,6 +39,6 @@ public interface IndexRow {
      * @param columnName the column name
      * @return the value, or null if not available
      */
-    CoreValue getValue(String columnName);
+    PropertyValue getValue(String columnName);
 
 }

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/PropertyValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/PropertyValue.java?rev=1397098&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/PropertyValue.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/PropertyValue.java Thu Oct 11 14:58:28 2012
@@ -0,0 +1,173 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.jackrabbit.oak.spi.query;
+
+import java.util.Calendar;
+import java.util.Iterator;
+
+import javax.jcr.PropertyType;
+
+import org.apache.jackrabbit.oak.api.PropertyState;
+import org.apache.jackrabbit.oak.api.Type;
+import org.apache.jackrabbit.util.ISO8601;
+
+public class PropertyValue implements PropertyState, Comparable<PropertyValue> {
+
+    private final PropertyState ps;
+
+    protected PropertyValue(PropertyState ps) {
+        this.ps = ps;
+    }
+
+    public String getName() {
+        return ps.getName();
+    }
+
+    public boolean isArray() {
+        return ps.isArray();
+    }
+
+    public Type<?> getType() {
+        return ps.getType();
+    }
+
+    public <T> T getValue(Type<T> type) {
+        return ps.getValue(type);
+    }
+
+    public <T> T getValue(Type<T> type, int index) {
+        return ps.getValue(type, index);
+    }
+
+    public long size() {
+        return ps.size();
+    }
+
+    public long size(int index) {
+        return ps.size(index);
+    }
+
+    public int count() {
+        return ps.count();
+    }
+
+    public PropertyState unwrap() {
+        return ps;
+    }
+
+    public int compareTo(PropertyValue p2) {
+        if (getType().tag() != p2.getType().tag()) {
+            return Integer.signum(getType().tag() - p2.getType().tag());
+        }
+        switch (getType().tag()) {
+        case PropertyType.BINARY:
+            return compare(getValue(Type.BINARIES), p2.getValue(Type.BINARIES));
+        case PropertyType.DOUBLE:
+            return compare(getValue(Type.DOUBLES), p2.getValue(Type.DOUBLES));
+        case PropertyType.DATE:
+            return compareAsDate(getValue(Type.STRINGS),
+                    p2.getValue(Type.STRINGS));
+        default:
+            return compare(getValue(Type.STRINGS), p2.getValue(Type.STRINGS));
+        }
+    }
+
+    private static <T extends Comparable<T>> int compare(Iterable<T> p1,
+            Iterable<T> p2) {
+        Iterator<T> i1 = p1.iterator();
+        Iterator<T> i2 = p2.iterator();
+        while (i1.hasNext() || i2.hasNext()) {
+            if (!i1.hasNext()) {
+                return 1;
+            }
+            if (!i2.hasNext()) {
+                return -1;
+            }
+            int compare = i1.next().compareTo(i2.next());
+            if (compare != 0) {
+                return compare;
+            }
+        }
+        return 0;
+    }
+
+    private static int compareAsDate(Iterable<String> p1, Iterable<String> p2) {
+        Iterator<String> i1 = p1.iterator();
+        Iterator<String> i2 = p2.iterator();
+        while (i1.hasNext() || i2.hasNext()) {
+            if (!i1.hasNext()) {
+                return 1;
+            }
+            if (!i2.hasNext()) {
+                return -1;
+            }
+            String v1 = i1.next();
+            String v2 = i2.next();
+
+            Calendar c1 = ISO8601.parse(v1);
+            Calendar c2 = ISO8601.parse(v2);
+            int compare = -1;
+            if (c1 != null && c2 != null) {
+                compare = c1.compareTo(c2);
+            } else {
+                compare = v1.compareTo(v2);
+            }
+            if (compare != 0) {
+                return compare;
+            }
+        }
+        return 0;
+    }
+
+    // --------------------------------------------------------------< Object >
+
+    private String getInternalString() {
+        StringBuilder sb = new StringBuilder();
+        Iterator<String> iterator = getValue(Type.STRINGS).iterator();
+        while (iterator.hasNext()) {
+            sb.append(iterator.next());
+            if (iterator.hasNext()) {
+                sb.append(",");
+            }
+        }
+        return sb.toString();
+    }
+
+    @Override
+    public int hashCode() {
+        return getType().tag() ^ getInternalString().hashCode();
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (o == this) {
+            return true;
+        } else if (o instanceof PropertyValue) {
+            return compareTo((PropertyValue) o) == 0;
+        } else {
+            return false;
+        }
+    }
+
+    @Override
+    public String toString() {
+        return getInternalString();
+    }
+
+}

Propchange: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/PropertyValue.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/PropertyValue.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/PropertyValues.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/PropertyValues.java?rev=1397098&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/PropertyValues.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/PropertyValues.java Thu Oct 11 14:58:28 2012
@@ -0,0 +1,246 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.jackrabbit.oak.spi.query;
+
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.util.Iterator;
+
+import javax.annotation.CheckForNull;
+import javax.annotation.Nonnull;
+import javax.jcr.PropertyType;
+
+import org.apache.jackrabbit.oak.api.PropertyState;
+import org.apache.jackrabbit.oak.api.Type;
+import org.apache.jackrabbit.oak.namepath.NamePathMapper;
+import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
+
+public class PropertyValues {
+
+    private PropertyValues() {
+    }
+
+    // TODO consistent naming
+
+    @CheckForNull
+    public static PropertyValue create(PropertyState property) {
+        if (property == null) {
+            return null;
+        }
+        return new PropertyValue(property);
+    }
+
+    @Nonnull
+    public static PropertyValue newString(String value) {
+        return new PropertyValue(PropertyStates.stringProperty("", value));
+    }
+
+    @Nonnull
+    public static PropertyValue newString(Iterable<String> value) {
+        return new PropertyValue(PropertyStates.stringProperty("", value));
+    }
+
+    @Nonnull
+    public static PropertyValue newLong(Long value) {
+        return new PropertyValue(PropertyStates.longProperty("", value));
+    }
+
+    @Nonnull
+    public static PropertyValue newDouble(Double value) {
+        return new PropertyValue(PropertyStates.doubleProperty("", value));
+    }
+
+    @Nonnull
+    public static PropertyValue newDecimal(BigDecimal value) {
+        return new PropertyValue(PropertyStates.decimalProperty("", value));
+    }
+
+    @Nonnull
+    public static PropertyValue newBoolean(boolean value) {
+        return new PropertyValue(PropertyStates.booleanProperty("", value));
+    }
+
+    @Nonnull
+    public static PropertyValue newDate(String value) {
+        return new PropertyValue(PropertyStates.dateProperty("", value));
+    }
+
+    @Nonnull
+    public static PropertyValue newName(String value) {
+        return new PropertyValue(PropertyStates.nameProperty("", value));
+    }
+
+    @Nonnull
+    public static PropertyValue newPath(String value) {
+        return new PropertyValue(PropertyStates.pathProperty("", value));
+    }
+
+    @Nonnull
+    public static PropertyValue newReference(String value) {
+        return new PropertyValue(PropertyStates.referenceProperty("", value));
+    }
+
+    @Nonnull
+    public static PropertyValue newWeakReference(String value) {
+        return new PropertyValue(
+                PropertyStates.weakreferenceProperty("", value));
+    }
+
+    @Nonnull
+    public static PropertyValue newUri(String value) {
+        return new PropertyValue(PropertyStates.uriProperty("", value));
+    }
+
+    @Nonnull
+    public static PropertyValue newBinary(byte[] value) {
+        return new PropertyValue(PropertyStates.binaryProperty("", value));
+    }
+
+    // --
+
+    public static boolean match(PropertyValue p1, PropertyState p2) {
+        return match(p1, create(p2));
+    }
+
+    public static boolean match(PropertyState p1, PropertyValue p2) {
+        return match(create(p1), p2);
+    }
+
+    public static boolean match(PropertyValue p1, PropertyValue p2) {
+        if (p1.getType().tag() != p2.getType().tag()) {
+            return false;
+        }
+
+        switch (p1.getType().tag()) {
+        case PropertyType.BINARY:
+            if (p1.isArray() && !p2.isArray()) {
+                return contains(p1.getValue(Type.BINARIES),
+                        p2.getValue(Type.BINARY));
+            }
+            if (!p1.isArray() && p2.isArray()) {
+                return contains(p2.getValue(Type.BINARIES),
+                        p2.getValue(Type.BINARY));
+            }
+        default:
+            if (p1.isArray() && !p2.isArray()) {
+                return contains(p1.getValue(Type.STRINGS),
+                        p2.getValue(Type.STRING));
+            }
+            if (!p1.isArray() && p2.isArray()) {
+                return contains(p2.getValue(Type.STRINGS),
+                        p2.getValue(Type.STRING));
+            }
+        }
+        // both arrays or both single values
+        return p1.compareTo(p2) == 0;
+
+    }
+
+    private static <T extends Comparable<T>> boolean contains(Iterable<T> p1,
+            T p2) {
+        Iterator<T> i1 = p1.iterator();
+        while (i1.hasNext()) {
+            int compare = i1.next().compareTo(p2);
+            if (compare == 0) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    // --
+    /**
+     * Convert a value to the given target type, if possible.
+     * 
+     * @param v
+     *            the value to convert
+     * @param targetType
+     *            the target property type
+     * @return the converted value, or null if converting is not possible
+     */
+    public static PropertyValue convert(PropertyState value, int targetType,
+            NamePathMapper mapper) {
+        // TODO support full set of conversion features defined in the JCR spec
+        // at 3.6.4 Property Type Conversion
+        // re-use existing code if possible
+        try {
+            switch (targetType) {
+            case PropertyType.STRING:
+                return newString(value.getValue(Type.STRING));
+            case PropertyType.DATE:
+                return newDate(value.getValue(Type.STRING));
+            case PropertyType.LONG:
+                return newLong(value.getValue(Type.LONG));
+            case PropertyType.DOUBLE:
+                return newDouble(value.getValue(Type.DOUBLE));
+            case PropertyType.DECIMAL:
+                return newDecimal(value.getValue(Type.DECIMAL));
+            case PropertyType.BOOLEAN:
+                return newBoolean(value.getValue(Type.BOOLEAN));
+            case PropertyType.NAME:
+                return newName(getOakPath(value.getValue(Type.STRING), mapper));
+            case PropertyType.PATH:
+                return newPath(value.getValue(Type.STRING));
+            case PropertyType.REFERENCE:
+                return newReference(value.getValue(Type.STRING));
+            case PropertyType.WEAKREFERENCE:
+                return newWeakReference(value.getValue(Type.STRING));
+            case PropertyType.URI:
+                return newUri(value.getValue(Type.STRING));
+            case PropertyType.BINARY:
+                try {
+                    byte[] data = value.getValue(Type.STRING).getBytes("UTF-8");
+                    return newBinary(data);
+                } catch (IOException e) {
+                    // I don't know in what case that could really occur
+                    // except if UTF-8 isn't supported
+                    throw new IllegalArgumentException(
+                            value.getValue(Type.STRING), e);
+                }
+            }
+            return null;
+            // throw new IllegalArgumentException("Unknown property type: " +
+            // targetType);
+        } catch (UnsupportedOperationException e) {
+            // TODO detect unsupported conversions, so that no exception is
+            // thrown
+            // because exceptions are slow
+            return null;
+            // throw new IllegalArgumentException("<unsupported conversion of "
+            // +
+            // v + " (" + PropertyType.nameFromValue(v.getType()) + ") to type "
+            // +
+            // PropertyType.nameFromValue(targetType) + ">");
+        }
+    }
+
+    public static String getOakPath(String jcrPath, NamePathMapper mapper) {
+        if (mapper == null) {
+            // to simplify testing, a getNamePathMapper isn't required
+            return jcrPath;
+        }
+        String p = mapper.getOakPath(jcrPath);
+        if (p == null) {
+            throw new IllegalArgumentException("Not a valid JCR path: "
+                    + jcrPath);
+        }
+        return p;
+    }
+
+}

Propchange: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/PropertyValues.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/PropertyValues.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java?rev=1397098&r1=1397097&r2=1397098&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java Thu Oct 11 14:58:28 2012
@@ -16,6 +16,10 @@
  */
 package org.apache.jackrabbit.oak.plugins.index.lucene;
 
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertFalse;
+import static junit.framework.Assert.assertTrue;
+
 import javax.security.auth.Subject;
 
 import org.apache.jackrabbit.mk.core.MicroKernelImpl;
@@ -25,20 +29,16 @@ import org.apache.jackrabbit.oak.core.Ro
 import org.apache.jackrabbit.oak.kernel.KernelNodeStore;
 import org.apache.jackrabbit.oak.plugins.index.IndexDefinition;
 import org.apache.jackrabbit.oak.plugins.index.IndexDefinitionImpl;
-import org.apache.jackrabbit.oak.plugins.memory.MemoryValueFactory;
 import org.apache.jackrabbit.oak.query.ast.Operator;
 import org.apache.jackrabbit.oak.query.index.FilterImpl;
 import org.apache.jackrabbit.oak.security.authorization.AccessControlProviderImpl;
 import org.apache.jackrabbit.oak.spi.query.CompositeQueryIndexProvider;
 import org.apache.jackrabbit.oak.spi.query.Cursor;
 import org.apache.jackrabbit.oak.spi.query.Filter;
+import org.apache.jackrabbit.oak.spi.query.PropertyValues;
 import org.apache.jackrabbit.oak.spi.query.QueryIndex;
 import org.junit.Test;
 
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertFalse;
-import static junit.framework.Assert.assertTrue;
-
 public class LuceneIndexTest implements LuceneIndexConstants {
 
     @Test
@@ -62,7 +62,7 @@ public class LuceneIndexTest implements 
         FilterImpl filter = new FilterImpl(null);
         filter.restrictPath("/", Filter.PathRestriction.EXACT);
         filter.restrictProperty("foo", Operator.EQUAL,
-                MemoryValueFactory.INSTANCE.createValue("bar"));
+                PropertyValues.newString("bar"));
         Cursor cursor = index.query(filter, store.getRoot());
         assertTrue(cursor.next());
         assertEquals("/", cursor.currentRow().getPath());

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java?rev=1397098&r1=1397097&r2=1397098&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java Thu Oct 11 14:58:28 2012
@@ -33,19 +33,22 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.oak.AbstractOakTest;
 import org.apache.jackrabbit.oak.api.ContentSession;
-import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.api.CoreValueFactory;
 import org.apache.jackrabbit.oak.api.Result;
 import org.apache.jackrabbit.oak.api.ResultRow;
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.api.SessionQueryEngine;
 import org.apache.jackrabbit.oak.api.Tree;
+import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.plugins.index.IndexConstants;
+import org.apache.jackrabbit.oak.spi.query.PropertyValue;
+import org.apache.jackrabbit.oak.spi.query.PropertyValues;
 import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
@@ -107,7 +110,7 @@ public abstract class AbstractQueryTest 
     }
 
     protected Result executeQuery(String statement, String language,
-            HashMap<String, CoreValue> sv) throws ParseException {
+            Map<String, PropertyValue> sv) throws ParseException {
         return qe.executeQuery(statement, language, Long.MAX_VALUE, 0, sv,
                 session.getLatestRoot(), null);
     }
@@ -141,15 +144,15 @@ public abstract class AbstractQueryTest 
                 vf);
         root.commit();
 
-        HashMap<String, CoreValue> sv = new HashMap<String, CoreValue>();
-        sv.put("id", vf.createValue("1"));
+        Map<String, PropertyValue> sv = new HashMap<String, PropertyValue>();
+        sv.put("id", PropertyValues.newString("1"));
         Iterator<? extends ResultRow> result;
         result = executeQuery("select * from [nt:base] where id = $id",
                 QueryEngineImpl.SQL2, sv).getRows().iterator();
         assertTrue(result.hasNext());
         assertEquals("/test/hello", result.next().getPath());
 
-        sv.put("id", vf.createValue("2"));
+        sv.put("id", PropertyValues.newString("2"));
         result = executeQuery("select * from [nt:base] where id = $id",
                 QueryEngineImpl.SQL2, sv).getRows().iterator();
         assertTrue(result.hasNext());
@@ -288,13 +291,13 @@ public abstract class AbstractQueryTest 
 
     protected static String readRow(ResultRow row) {
         StringBuilder buff = new StringBuilder();
-        CoreValue[] values = row.getValues();
+        PropertyValue[] values = row.getValues();
         for (int i = 0; i < values.length; i++) {
             if (i > 0) {
                 buff.append(", ");
             }
-            CoreValue v = values[i];
-            buff.append(v == null ? "null" : v.getString());
+            PropertyValue v = values[i];
+            buff.append(v == null ? "null" : v.getValue(Type.STRING));
         }
         return buff.toString();
     }

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/FilterTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/FilterTest.java?rev=1397098&r1=1397097&r2=1397098&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/FilterTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/FilterTest.java Thu Oct 11 14:58:28 2012
@@ -25,10 +25,10 @@ import static org.junit.Assert.fail;
 import java.util.ArrayList;
 import java.util.Random;
 
-import org.apache.jackrabbit.oak.api.CoreValue;
-import org.apache.jackrabbit.oak.plugins.memory.StringValue;
 import org.apache.jackrabbit.oak.query.ast.Operator;
 import org.apache.jackrabbit.oak.spi.query.Filter;
+import org.apache.jackrabbit.oak.spi.query.PropertyValue;
+import org.apache.jackrabbit.oak.spi.query.PropertyValues;
 import org.junit.Test;
 
 /**
@@ -39,8 +39,8 @@ public class FilterTest {
     @Test
     public void propertyRestriction() {
 
-        CoreValue one = new StringValue("1");
-        CoreValue two = new StringValue("2");
+        PropertyValue one = PropertyValues.newString("1");
+        PropertyValue two = PropertyValues.newString("2");
 
         FilterImpl f = new FilterImpl(null);
         assertTrue(null == f.getPropertyRestriction("x"));
@@ -104,8 +104,10 @@ public class FilterTest {
         for (int i = 0; i < 10000; i++) {
             String p1 = paths.get(r.nextInt(paths.size()));
             String p2 = paths.get(r.nextInt(paths.size()));
-            Filter.PathRestriction r1 = Filter.PathRestriction.values()[r.nextInt(Filter.PathRestriction.values().length)];
-            Filter.PathRestriction r2 = Filter.PathRestriction.values()[r.nextInt(Filter.PathRestriction.values().length)];
+            Filter.PathRestriction r1 = Filter.PathRestriction.values()[r
+                    .nextInt(Filter.PathRestriction.values().length)];
+            Filter.PathRestriction r2 = Filter.PathRestriction.values()[r
+                    .nextInt(Filter.PathRestriction.values().length)];
             FilterImpl f1 = new FilterImpl(null);
             f1.restrictPath(p1, r1);
             FilterImpl f2 = new FilterImpl(null);
@@ -123,14 +125,16 @@ public class FilterTest {
                     fc = new FilterImpl(null);
                     fc.restrictPath(p1, r1);
                     fc.restrictPath(p2, r2);
-                    fail("not matched: " + p1 + "/" + r1.name() + " && " + p2 + "/" + r2.name());
+                    fail("not matched: " + p1 + "/" + r1.name() + " && " + p2
+                            + "/" + r2.name());
                 } else {
                     // not great, but not a problem
                     tooMany++;
                 }
             }
             if (tooMany > 3) {
-                fail("too many matches: " + p1 + "/" + r1.name() + " && " + p2 + "/" + r2.name() + " superfluous: " + tooMany);
+                fail("too many matches: " + p1 + "/" + r1.name() + " && " + p2
+                        + "/" + r2.name() + " superfluous: " + tooMany);
             }
         }
     }
@@ -139,7 +143,8 @@ public class FilterTest {
     public void pathRestrictions() throws Exception {
         FilterImpl f = new FilterImpl(null);
         assertEquals("/", f.getPath());
-        assertEquals(Filter.PathRestriction.ALL_CHILDREN, f.getPathRestriction());
+        assertEquals(Filter.PathRestriction.ALL_CHILDREN,
+                f.getPathRestriction());
 
         f.restrictPath("/test", Filter.PathRestriction.ALL_CHILDREN);
         f.restrictPath("/test2", Filter.PathRestriction.ALL_CHILDREN);
@@ -148,10 +153,12 @@ public class FilterTest {
         f = new FilterImpl(null);
         f.restrictPath("/test", Filter.PathRestriction.ALL_CHILDREN);
         assertEquals("/test", f.getPath());
-        assertEquals(Filter.PathRestriction.ALL_CHILDREN, f.getPathRestriction());
+        assertEquals(Filter.PathRestriction.ALL_CHILDREN,
+                f.getPathRestriction());
         f.restrictPath("/test/x", Filter.PathRestriction.DIRECT_CHILDREN);
         assertEquals("/test/x", f.getPath());
-        assertEquals(Filter.PathRestriction.DIRECT_CHILDREN, f.getPathRestriction());
+        assertEquals(Filter.PathRestriction.DIRECT_CHILDREN,
+                f.getPathRestriction());
         f.restrictPath("/test/x/y", Filter.PathRestriction.PARENT);
         assertEquals("/test/x/y", f.getPath());
         assertEquals(Filter.PathRestriction.PARENT, f.getPathRestriction());
@@ -212,13 +219,16 @@ public class FilterTest {
         f = new FilterImpl(null);
         f.restrictPath("/test", Filter.PathRestriction.DIRECT_CHILDREN);
         assertEquals("/test", f.getPath());
-        assertEquals(Filter.PathRestriction.DIRECT_CHILDREN, f.getPathRestriction());
+        assertEquals(Filter.PathRestriction.DIRECT_CHILDREN,
+                f.getPathRestriction());
         f.restrictPath("/", Filter.PathRestriction.ALL_CHILDREN);
         assertEquals("/test", f.getPath());
-        assertEquals(Filter.PathRestriction.DIRECT_CHILDREN, f.getPathRestriction());
+        assertEquals(Filter.PathRestriction.DIRECT_CHILDREN,
+                f.getPathRestriction());
         f.restrictPath("/test", Filter.PathRestriction.ALL_CHILDREN);
         assertEquals("/test", f.getPath());
-        assertEquals(Filter.PathRestriction.DIRECT_CHILDREN, f.getPathRestriction());
+        assertEquals(Filter.PathRestriction.DIRECT_CHILDREN,
+                f.getPathRestriction());
         f.restrictPath("/test/x/y", Filter.PathRestriction.PARENT);
         assertEquals("/test/x/y", f.getPath());
         assertEquals(Filter.PathRestriction.PARENT, f.getPathRestriction());

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryManagerImpl.java?rev=1397098&r1=1397097&r2=1397098&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryManagerImpl.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryManagerImpl.java Thu Oct 11 14:58:28 2012
@@ -23,7 +23,9 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
 import java.util.Map.Entry;
+
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
@@ -33,12 +35,15 @@ import javax.jcr.query.Query;
 import javax.jcr.query.QueryManager;
 import javax.jcr.query.QueryResult;
 import javax.jcr.query.qom.QueryObjectModelFactory;
-import org.apache.jackrabbit.oak.api.CoreValue;
-import org.apache.jackrabbit.oak.api.SessionQueryEngine;
+
 import org.apache.jackrabbit.oak.api.Result;
+import org.apache.jackrabbit.oak.api.SessionQueryEngine;
 import org.apache.jackrabbit.oak.jcr.SessionDelegate;
 import org.apache.jackrabbit.oak.jcr.query.qom.QueryObjectModelFactoryImpl;
 import org.apache.jackrabbit.oak.namepath.NamePathMapper;
+import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
+import org.apache.jackrabbit.oak.spi.query.PropertyValue;
+import org.apache.jackrabbit.oak.spi.query.PropertyValues;
 
 /**
  * The implementation of the corresponding JCR interface.
@@ -110,7 +115,7 @@ public class QueryManagerImpl implements
     public QueryResult executeQuery(String statement, String language,
             long limit, long offset, HashMap<String, Value> bindVariableMap) throws RepositoryException {
         try {
-            HashMap<String, CoreValue> bindMap = convertMap(bindVariableMap);
+            Map<String, PropertyValue> bindMap = convertMap(bindVariableMap);
             NamePathMapper namePathMapper = sessionDelegate.getNamePathMapper();
             Result r = queryEngine.executeQuery(statement, language, limit, offset,
                     bindMap, sessionDelegate.getRoot(), namePathMapper);
@@ -122,10 +127,13 @@ public class QueryManagerImpl implements
         }
     }
 
-    private HashMap<String, CoreValue> convertMap(HashMap<String, Value> bindVariableMap) {
-        HashMap<String, CoreValue> map = new HashMap<String, CoreValue>();
+    private Map<String, PropertyValue> convertMap(
+            HashMap<String, Value> bindVariableMap) throws RepositoryException {
+        HashMap<String, PropertyValue> map = new HashMap<String, PropertyValue>();
         for (Entry<String, Value> e : bindVariableMap.entrySet()) {
-            map.put(e.getKey(), sessionDelegate.getValueFactory().getCoreValue(e.getValue()));
+            map.put(e.getKey(),
+                    PropertyValues.create(PropertyStates.createProperty("",
+                            e.getValue())));
         }
         return map;
     }

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryResultImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryResultImpl.java?rev=1397098&r1=1397097&r2=1397098&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryResultImpl.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryResultImpl.java Thu Oct 11 14:58:28 2012
@@ -30,13 +30,14 @@ import javax.jcr.query.RowIterator;
 
 import org.apache.jackrabbit.commons.iterator.NodeIteratorAdapter;
 import org.apache.jackrabbit.commons.iterator.RowIteratorAdapter;
-import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.api.Result;
 import org.apache.jackrabbit.oak.api.ResultRow;
 import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.jcr.NodeDelegate;
 import org.apache.jackrabbit.oak.jcr.NodeImpl;
 import org.apache.jackrabbit.oak.jcr.SessionDelegate;
+import org.apache.jackrabbit.oak.plugins.memory.CoreValues;
+import org.apache.jackrabbit.oak.spi.query.PropertyValue;
 
 /**
  * The implementation of the corresponding JCR interface.
@@ -227,8 +228,8 @@ public class QueryResultImpl implements 
         };
     }
 
-    Value createValue(CoreValue value) {
-        return value == null ? null : sessionDelegate.getValueFactory().createValue(value);
+    Value createValue(PropertyValue value) {
+        return value == null ? null : sessionDelegate.getValueFactory().createValue(CoreValues.getValue(value));
     }
 
 }

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/RowImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/RowImpl.java?rev=1397098&r1=1397097&r2=1397098&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/RowImpl.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/RowImpl.java Thu Oct 11 14:58:28 2012
@@ -22,8 +22,9 @@ import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 import javax.jcr.query.Row;
-import org.apache.jackrabbit.oak.api.CoreValue;
+
 import org.apache.jackrabbit.oak.api.ResultRow;
+import org.apache.jackrabbit.oak.spi.query.PropertyValue;
 
 /**
  * The implementation of the corresponding JCR interface.
@@ -89,7 +90,7 @@ public class RowImpl implements Row {
 
     @Override
     public Value[] getValues() throws RepositoryException {
-        CoreValue[] values = row.getValues();
+        PropertyValue[] values = row.getValues();
         int len = values.length;
         Value[] v2 = new Value[values.length];
         for (int i = 0; i < len; i++) {



Mime
View raw message