jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1416548 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: query/ast/ spi/query/
Date Mon, 03 Dec 2012 14:42:28 GMT
Author: thomasm
Date: Mon Dec  3 14:42:25 2012
New Revision: 1416548

URL: http://svn.apache.org/viewvc?rev=1416548&view=rev
Log:
OAK-473 Query tck test NodeNameTest fix

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/BindVariableValueImpl.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/DynamicOperandImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/FullTextSearchScoreImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/LengthImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/LiteralImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/LowerCaseImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/NodeLocalNameImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/NodeNameImpl.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/query/ast/StaticOperandImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/UpperCaseImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/PropertyValues.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/BindVariableValueImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/BindVariableValueImpl.java?rev=1416548&r1=1416547&r2=1416548&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/BindVariableValueImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/BindVariableValueImpl.java
Mon Dec  3 14:42:25 2012
@@ -18,6 +18,8 @@
  */
 package org.apache.jackrabbit.oak.query.ast;
 
+import javax.jcr.PropertyType;
+
 import org.apache.jackrabbit.oak.api.PropertyValue;
 
 
@@ -50,5 +52,11 @@ public class BindVariableValueImpl exten
     PropertyValue currentValue() {
         return query.getBindVariableValue(bindVariableName);
     }
+    
+    @Override
+    int getPropertyType() {
+        PropertyValue v = currentValue();
+        return v == null ? PropertyType.UNDEFINED : v.getType().tag();
+    }
 
 }

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=1416548&r1=1416547&r2=1416548&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
Mon Dec  3 14:42:25 2012
@@ -18,6 +18,8 @@
  */
 package org.apache.jackrabbit.oak.query.ast;
 
+import javax.jcr.PropertyType;
+
 import org.apache.jackrabbit.oak.api.PropertyValue;
 import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.query.index.FilterImpl;
@@ -135,9 +137,16 @@ public class ComparisonImpl extends Cons
     @Override
     public void restrict(FilterImpl f) {
         PropertyValue v = operand2.currentValue();
+        if (!PropertyValues.canConvert(
+                operand2.getPropertyType(), 
+                operand1.getPropertyType())) {
+            throw new IllegalArgumentException(
+                    "Unsupported conversion from property type " + 
+                            PropertyType.nameFromValue(operand2.getPropertyType()) + 
+                            " to property type " +
+                            PropertyType.nameFromValue(operand1.getPropertyType()));
+        }
         if (v != null) {
-       //     operand1.restrict(f, operator, v);
-            // TODO OAK-347
             if (operator == Operator.LIKE) {
                 String pattern;
                 pattern = v.getValue(Type.STRING);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/DynamicOperandImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/DynamicOperandImpl.java?rev=1416548&r1=1416547&r2=1416548&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/DynamicOperandImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/DynamicOperandImpl.java
Mon Dec  3 14:42:25 2012
@@ -43,4 +43,6 @@ public abstract class DynamicOperandImpl
         return true;
     }
 
+    abstract int getPropertyType();
+
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/FullTextSearchScoreImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/FullTextSearchScoreImpl.java?rev=1416548&r1=1416547&r2=1416548&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/FullTextSearchScoreImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/FullTextSearchScoreImpl.java
Mon Dec  3 14:42:25 2012
@@ -18,6 +18,8 @@
  */
 package org.apache.jackrabbit.oak.query.ast;
 
+import javax.jcr.PropertyType;
+
 import org.apache.jackrabbit.oak.api.PropertyValue;
 import org.apache.jackrabbit.oak.query.Query;
 import org.apache.jackrabbit.oak.query.index.FilterImpl;
@@ -74,5 +76,10 @@ public class FullTextSearchScoreImpl ext
     public boolean canRestrictSelector(SelectorImpl s) {
         return s == selector;
     }
+    
+    @Override
+    int getPropertyType() {
+        return PropertyType.DOUBLE;
+    }
 
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/LengthImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/LengthImpl.java?rev=1416548&r1=1416547&r2=1416548&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/LengthImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/LengthImpl.java
Mon Dec  3 14:42:25 2012
@@ -92,5 +92,10 @@ public class LengthImpl extends DynamicO
     public boolean canRestrictSelector(SelectorImpl s) {
         return propertyValue.canRestrictSelector(s);
     }
+    
+    @Override
+    int getPropertyType() {
+        return PropertyType.LONG;
+    }
 
 }

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=1416548&r1=1416547&r2=1416548&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
Mon Dec  3 14:42:25 2012
@@ -60,5 +60,11 @@ public class LiteralImpl extends StaticO
     PropertyValue currentValue() {
         return value;
     }
+    
+    @Override
+    int getPropertyType() {
+        PropertyValue v = currentValue();
+        return v == null ? PropertyType.UNDEFINED : v.getType().tag();
+    }
 
 }

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=1416548&r1=1416547&r2=1416548&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
Mon Dec  3 14:42:25 2012
@@ -18,6 +18,8 @@
  */
 package org.apache.jackrabbit.oak.query.ast;
 
+import javax.jcr.PropertyType;
+
 import org.apache.jackrabbit.oak.api.PropertyValue;
 import org.apache.jackrabbit.oak.query.index.FilterImpl;
 import org.apache.jackrabbit.oak.spi.query.PropertyValues;
@@ -71,5 +73,10 @@ public class LowerCaseImpl extends Dynam
     public boolean canRestrictSelector(SelectorImpl s) {
         return operand.canRestrictSelector(s);
     }
+    
+    @Override
+    int getPropertyType() {
+        return PropertyType.STRING;
+    }
 
 }

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=1416548&r1=1416547&r2=1416548&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
Mon Dec  3 14:42:25 2012
@@ -18,6 +18,8 @@
  */
 package org.apache.jackrabbit.oak.query.ast;
 
+import javax.jcr.PropertyType;
+
 import org.apache.jackrabbit.oak.api.PropertyValue;
 import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.query.index.FilterImpl;
@@ -70,5 +72,10 @@ public class NodeLocalNameImpl extends D
     public boolean canRestrictSelector(SelectorImpl s) {
         return s == selector;
     }
+    
+    @Override
+    int getPropertyType() {
+        return PropertyType.STRING;
+    }
 
 }

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=1416548&r1=1416547&r2=1416548&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
Mon Dec  3 14:42:25 2012
@@ -121,5 +121,10 @@ public class NodeNameImpl extends Dynami
         }
         return true;
     }
+    
+    @Override
+    int getPropertyType() {
+        return PropertyType.NAME;
+    }
 
 }

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=1416548&r1=1416547&r2=1416548&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
Mon Dec  3 14:42:25 2012
@@ -182,5 +182,10 @@ public class PropertyValueImpl extends D
     public boolean canRestrictSelector(SelectorImpl s) {
         return s == selector;
     }
+    
+    @Override
+    int getPropertyType() {
+        return propertyType;
+    }
 
 }

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=1416548&r1=1416547&r2=1416548&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
Mon Dec  3 14:42:25 2012
@@ -27,4 +27,6 @@ public abstract class StaticOperandImpl 
 
     abstract PropertyValue currentValue();
 
+    abstract int getPropertyType();
+
 }

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=1416548&r1=1416547&r2=1416548&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
Mon Dec  3 14:42:25 2012
@@ -18,6 +18,8 @@
  */
 package org.apache.jackrabbit.oak.query.ast;
 
+import javax.jcr.PropertyType;
+
 import org.apache.jackrabbit.oak.api.PropertyValue;
 import org.apache.jackrabbit.oak.query.index.FilterImpl;
 import org.apache.jackrabbit.oak.spi.query.PropertyValues;
@@ -71,5 +73,10 @@ public class UpperCaseImpl extends Dynam
     public boolean canRestrictSelector(SelectorImpl s) {
         return operand.canRestrictSelector(s);
     }
+    
+    @Override
+    int getPropertyType() {
+        return PropertyType.STRING;
+    }
 
 }

Modified: 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=1416548&r1=1416547&r2=1416548&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/PropertyValues.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/PropertyValues.java
Mon Dec  3 14:42:25 2012
@@ -243,17 +243,25 @@ public final class PropertyValues {
             // 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) + ">");
+            throw new IllegalArgumentException(
+                    "Unsupported conversion from type " + value + 
+                    " (" + PropertyType.nameFromValue(value.getType().tag()) + ") to type
" +
+                            PropertyType.nameFromValue(targetType));
         }
     }
+    
+    public static boolean canConvert(int sourceType, int targetType) {
+        // TODO support full set of conversion features defined in the JCR spec
+        // at 3.6.4 Property Type Conversion
+        switch (sourceType) {
+        case PropertyType.WEAKREFERENCE:
+        case PropertyType.REFERENCE:
+            if (targetType == PropertyType.NAME) {
+                return false;
+            }
+        }
+        return true;
+    }
 
     public static String getOakPath(String jcrPath, NamePathMapper mapper) {
         if (mapper == null) {



Mime
View raw message