jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1429885 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query: XPathToSQL2Converter.java ast/BindVariableValueImpl.java ast/ComparisonImpl.java
Date Mon, 07 Jan 2013 16:30:19 GMT
Author: thomasm
Date: Mon Jan  7 16:30:18 2013
New Revision: 1429885

URL: http://svn.apache.org/viewvc?rev=1429885&view=rev
Log:
OAK-28 Query implementation: fix code violations found by Sonar

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/XPathToSQL2Converter.java
    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

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/XPathToSQL2Converter.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/XPathToSQL2Converter.java?rev=1429885&r1=1429884&r2=1429885&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/XPathToSQL2Converter.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/XPathToSQL2Converter.java
Mon Jan  7 16:30:18 2013
@@ -824,7 +824,6 @@ public class XPathToSQL2Converter {
                 // the '-' can be part of a name,
                 // for example in "fn:lower-case"
                 if (type != CHAR_NAME && type != CHAR_VALUE && chars[i] !=
'-') {
-                    c = chars[i];
                     break;
                 }
                 i++;
@@ -840,7 +839,10 @@ public class XPathToSQL2Converter {
             if (types[i] == CHAR_SPECIAL_2) {
                 i++;
             }
-            // fall through
+            currentToken = statement.substring(start, i);
+            currentTokenType = KEYWORD;
+            parseIndex = i;
+            break;
         case CHAR_SPECIAL_1:
             currentToken = statement.substring(start, i);
             switch (c) {

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=1429885&r1=1429884&r2=1429885&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 Jan  7 16:30:18 2013
@@ -18,8 +18,6 @@
  */
 package org.apache.jackrabbit.oak.query.ast;
 
-import javax.jcr.PropertyType;
-
 import org.apache.jackrabbit.oak.api.PropertyValue;
 
 /**
@@ -55,7 +53,7 @@ public class BindVariableValueImpl exten
     @Override
     int getPropertyType() {
         PropertyValue v = currentValue();
-        return v == null ? PropertyType.UNDEFINED : v.getType().tag();
+        return 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=1429885&r1=1429884&r2=1429885&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 Jan  7 16:30:18 2013
@@ -78,9 +78,6 @@ public class ComparisonImpl extends Cons
             // "the value of operand2 is converted to the
             // property type of the value of operand1"
             p2 = PropertyValues.convert(p2, v1Type, query.getNamePathMapper());
-            if (p2 == null) {
-                return false;
-            }
         }
         return evaluate(p1, p2);
     }
@@ -152,24 +149,24 @@ public class ComparisonImpl extends Cons
                 pattern = v.getValue(Type.STRING);
                 LikePattern p = new LikePattern(pattern);
                 String lowerBound = p.getLowerBound();
-                String upperBound = p.getUpperBound();
-                if (lowerBound == null && upperBound == null) {
-                    // ignore
-                } else if (lowerBound.equals(upperBound)) {
-                    // no wildcards
-                    operand1.restrict(f, Operator.EQUAL, v);
-                } else if (operand1.supportsRangeConditions()) {
-                    if (lowerBound != null) {
-                        PropertyValue pv = PropertyValues.newString(lowerBound);
-                        operand1.restrict(f, Operator.GREATER_OR_EQUAL, pv);
-                    }
-                    if (upperBound != null) {
-                        PropertyValue pv = PropertyValues.newString(upperBound);
-                        operand1.restrict(f, Operator.LESS_OR_EQUAL, pv);
+                if (lowerBound != null) {
+                    String upperBound = p.getUpperBound();
+                    if (lowerBound.equals(upperBound)) {
+                        // no wildcards
+                        operand1.restrict(f, Operator.EQUAL, v);
+                    } else if (operand1.supportsRangeConditions()) {
+                        if (lowerBound != null) {
+                            PropertyValue pv = PropertyValues.newString(lowerBound);
+                            operand1.restrict(f, Operator.GREATER_OR_EQUAL, pv);
+                        }
+                        if (upperBound != null) {
+                            PropertyValue pv = PropertyValues.newString(upperBound);
+                            operand1.restrict(f, Operator.LESS_OR_EQUAL, pv);
+                        }
+                    } else {
+                        // path conditions
+                        operand1.restrict(f, operator, v);
                     }
-                } else {
-                    // path conditions
-                    operand1.restrict(f, operator, v);
                 }
             } else {
                 operand1.restrict(f, operator, v);



Mime
View raw message