jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r770698 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint: ComparisonConstraint.java ConstraintBuilder.java LikeConstraint.java
Date Fri, 01 May 2009 14:46:45 GMT
Author: jukka
Date: Fri May  1 14:46:44 2009
New Revision: 770698

URL: http://svn.apache.org/viewvc?rev=770698&view=rev
Log:
JCR-2094: Use an enumeration for QOM operators

Use the Operator enumeration in query execution.

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/ComparisonConstraint.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/ConstraintBuilder.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/LikeConstraint.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/ComparisonConstraint.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/ComparisonConstraint.java?rev=770698&r1=770697&r2=770698&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/ComparisonConstraint.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/ComparisonConstraint.java
Fri May  1 14:46:44 2009
@@ -20,18 +20,17 @@
 
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
-import javax.jcr.query.qom.QueryObjectModelConstants;
 
 import org.apache.jackrabbit.core.query.lucene.ScoreNode;
 import org.apache.jackrabbit.core.query.lucene.Util;
 import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.commons.query.qom.Operator;
 import org.apache.jackrabbit.spi.commons.query.qom.SelectorImpl;
 
 /**
  * <code>ComparisonConstraint</code> implements a comparison constraint.
  */
-public class ComparisonConstraint extends SelectorBasedConstraint
-        implements QueryObjectModelConstants {
+public class ComparisonConstraint extends SelectorBasedConstraint {
 
     /**
      * The dynamic operand.
@@ -41,7 +40,7 @@
     /**
      * The operator.
      */
-    private final String operator;
+    private final Operator operator;
 
     /**
      * The static operand.
@@ -57,7 +56,7 @@
      * @param selector the selector for this constraint.
      */
     public ComparisonConstraint(DynamicOperand operand1,
-                                String operator,
+                                Operator operator,
                                 Value operand2,
                                 SelectorImpl selector) {
         super(selector);
@@ -101,20 +100,21 @@
      */
     protected boolean evaluate(Value op1) throws RepositoryException {
         int c = Util.compare(op1, operand2);
-        if (JCR_OPERATOR_EQUAL_TO.equals(operator)) {
+        if (operator == Operator.EQ) {
             return c == 0;
-        } else if (JCR_OPERATOR_GREATER_THAN.equals(operator)) {
+        } else if (operator == Operator.GT) {
             return c > 0;
-        } else if (JCR_OPERATOR_GREATER_THAN_OR_EQUAL_TO.equals(operator)) {
+        } else if (operator == Operator.GE) {
             return c >= 0;
-        } else if (JCR_OPERATOR_LESS_THAN.equals(operator)) {
+        } else if (operator == Operator.LT) {
             return c < 0;
-        } else if (JCR_OPERATOR_LESS_THAN_OR_EQUAL_TO.equals(operator)) {
+        } else if (operator == Operator.LE) {
             return c <= 0;
-        } else if (JCR_OPERATOR_NOT_EQUAL_TO.equals(operator)) {
+        } else if (operator == Operator.NE) {
             return c != 0;
         } else {
-            throw new IllegalStateException("unsupported operation: " + operator);
+            throw new UnsupportedOperationException(
+                    "Unsupported comparison operator: " + operator);
         }
     }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/ConstraintBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/ConstraintBuilder.java?rev=770698&r1=770697&r2=770698&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/ConstraintBuilder.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/ConstraintBuilder.java
Fri May  1 14:46:44 2009
@@ -24,7 +24,6 @@
 import javax.jcr.ValueFactory;
 import javax.jcr.ValueFormatException;
 import javax.jcr.query.InvalidQueryException;
-import javax.jcr.query.qom.QueryObjectModelConstants;
 
 import org.apache.jackrabbit.core.query.lucene.LuceneQueryFactory;
 import org.apache.jackrabbit.spi.Name;
@@ -48,6 +47,7 @@
 import org.apache.jackrabbit.spi.commons.query.qom.NodeLocalNameImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.NodeNameImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.NotImpl;
+import org.apache.jackrabbit.spi.commons.query.qom.Operator;
 import org.apache.jackrabbit.spi.commons.query.qom.OrImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.OrderingImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.PropertyExistenceImpl;
@@ -168,16 +168,17 @@
 
         public Object visit(ComparisonImpl node, Object data) throws Exception {
             DynamicOperandImpl op1 = (DynamicOperandImpl) node.getOperand1();
+            Operator operator = node.getOperatorInstance();
             StaticOperandImpl op2 = ((StaticOperandImpl) node.getOperand2());
             Value staticValue = (Value) op2.accept(this, null);
 
             DynamicOperand dynOp = (DynamicOperand) op1.accept(this, staticValue);
             SelectorImpl selector = getSelector(op1.getSelectorQName());
-            if (QueryObjectModelConstants.JCR_OPERATOR_LIKE.equals(node.getOperator())) {
+            if (operator == Operator.LIKE) {
                 return new LikeConstraint(dynOp, staticValue, selector);
             } else {
-                return new ComparisonConstraint(dynOp, node.getOperator(),
-                        staticValue, selector);
+                return new ComparisonConstraint(
+                        dynOp, operator, staticValue, selector);
             }
         }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/LikeConstraint.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/LikeConstraint.java?rev=770698&r1=770697&r2=770698&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/LikeConstraint.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/LikeConstraint.java
Fri May  1 14:46:44 2009
@@ -18,11 +18,12 @@
 
 import java.util.regex.Matcher;
 
-import javax.jcr.Value;
 import javax.jcr.RepositoryException;
+import javax.jcr.Value;
 
-import org.apache.jackrabbit.spi.commons.query.qom.SelectorImpl;
 import org.apache.jackrabbit.core.query.lucene.Util;
+import org.apache.jackrabbit.spi.commons.query.qom.Operator;
+import org.apache.jackrabbit.spi.commons.query.qom.SelectorImpl;
 
 /**
  * <code>LikeConstraint</code> implements a like constraint.
@@ -46,7 +47,7 @@
     public LikeConstraint(DynamicOperand operand1,
                           Value operand2,
                           SelectorImpl selector) throws RepositoryException {
-        super(operand1, JCR_OPERATOR_LIKE, operand2, selector);
+        super(operand1, Operator.LIKE, operand2, selector);
         this.matcher = Util.createRegexp(operand2.getString()).matcher("");
     }
 



Mime
View raw message