cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1510018 - in /cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne: exp/parser/ util/
Date Sat, 03 Aug 2013 15:50:35 GMT
Author: aadamchik
Date: Sat Aug  3 15:50:34 2013
New Revision: 1510018

URL: http://svn.apache.org/r1510018
Log:
CAY-1860  In-memory matching of DataObjects against ObjectId or int

switching other expressions to evaluator

Modified:
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTBetween.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTGreater.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTGreaterOrEqual.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTLess.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTLessOrEqual.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTNotBetween.java
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/util/ConversionUtil.java

Modified: cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTBetween.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTBetween.java?rev=1510018&r1=1510017&r2=1510018&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTBetween.java
(original)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTBetween.java
Sat Aug  3 15:50:34 2013
@@ -20,7 +20,6 @@
 package org.apache.cayenne.exp.parser;
 
 import org.apache.cayenne.exp.Expression;
-import org.apache.cayenne.util.ConversionUtil;
 
 /**
  * "Between" expression.
@@ -42,7 +41,7 @@ public class ASTBetween extends Conditio
         jjtAddChild(path, 0);
         jjtAddChild(new ASTScalar(value1), 1);
         jjtAddChild(new ASTScalar(value2), 2);
-        
+
         connectChildren();
     }
 
@@ -53,24 +52,12 @@ public class ASTBetween extends Conditio
             return Boolean.FALSE;
         }
 
-        Comparable c1 = ConversionUtil.toComparable(evaluateChild(0, o));
-
-        if (c1 == null) {
-            return Boolean.FALSE;
-        }
-
-        Comparable c2 = ConversionUtil.toComparable(evaluateChild(1, o));
-        if (c2 == null) {
-            return Boolean.FALSE;
-        }
-
-        Comparable c3 = ConversionUtil.toComparable(evaluateChild(2, o));
-        if (c3 == null) {
-            return Boolean.FALSE;
-        }
+        Object o1 = evaluateChild(0, o);
+        Object o2 = evaluateChild(1, o);
+        Object o3 = evaluateChild(2, o);
+        Evaluator e = Evaluator.evaluator(o1);
 
-        return c1.compareTo(c2) >= 0
-            && c1.compareTo(c3) <= 0 ? Boolean.TRUE : Boolean.FALSE;
+        return e.compare(o1, o2) >= 0 && e.compare(o1, o3) <= 0 ? Boolean.TRUE
: Boolean.FALSE;
     }
 
     /**

Modified: cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTGreater.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTGreater.java?rev=1510018&r1=1510017&r2=1510018&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTGreater.java
(original)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTGreater.java
Sat Aug  3 15:50:34 2013
@@ -20,11 +20,9 @@
 package org.apache.cayenne.exp.parser;
 
 import org.apache.cayenne.exp.Expression;
-import org.apache.cayenne.util.ConversionUtil;
 
 /**
- * "Greate Than" expression.
- * 
+ * "Greater Than" expression.
  */
 public class ASTGreater extends ConditionNode {
 
@@ -53,17 +51,11 @@ public class ASTGreater extends Conditio
             return Boolean.FALSE;
         }
 
-        Comparable c1 = ConversionUtil.toComparable(evaluateChild(0, o));
-        if (c1 == null) {
-            return Boolean.FALSE;
-        }
-
-        Comparable c2 = ConversionUtil.toComparable(evaluateChild(1, o));
-        if (c2 == null) {
-            return Boolean.FALSE;
-        }
+        Object o1 = evaluateChild(0, o);
+        Object o2 = evaluateChild(1, o);
+        int diff = Evaluator.evaluator(o1).compare(o1, o2);
 
-        return c1.compareTo(c2) > 0 ? Boolean.TRUE : Boolean.FALSE;
+        return diff > 0 ? Boolean.TRUE : Boolean.FALSE;
     }
 
     /**

Modified: cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTGreaterOrEqual.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTGreaterOrEqual.java?rev=1510018&r1=1510017&r2=1510018&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTGreaterOrEqual.java
(original)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTGreaterOrEqual.java
Sat Aug  3 15:50:34 2013
@@ -20,7 +20,6 @@
 package org.apache.cayenne.exp.parser;
 
 import org.apache.cayenne.exp.Expression;
-import org.apache.cayenne.util.ConversionUtil;
 
 /**
  * "Greater Than Or Equal To" expression.
@@ -54,17 +53,11 @@ public class ASTGreaterOrEqual extends C
             return Boolean.FALSE;
         }
 
-        Comparable c1 = ConversionUtil.toComparable(evaluateChild(0, o));
-        if (c1 == null) {
-            return Boolean.FALSE;
-        }
-
-        Comparable c2 = ConversionUtil.toComparable(evaluateChild(1, o));
-        if (c2 == null) {
-            return Boolean.FALSE;
-        }
+        Object o1 = evaluateChild(0, o);
+        Object o2 = evaluateChild(1, o);
+        int diff = Evaluator.evaluator(o1).compare(o1, o2);
 
-        return c1.compareTo(c2) >= 0 ? Boolean.TRUE : Boolean.FALSE;
+        return diff >= 0 ? Boolean.TRUE : Boolean.FALSE;
     }
 
     /**

Modified: cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTLess.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTLess.java?rev=1510018&r1=1510017&r2=1510018&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTLess.java
(original)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTLess.java
Sat Aug  3 15:50:34 2013
@@ -20,7 +20,6 @@
 package org.apache.cayenne.exp.parser;
 
 import org.apache.cayenne.exp.Expression;
-import org.apache.cayenne.util.ConversionUtil;
 
 /**
  * "Less Then" expression.
@@ -53,17 +52,11 @@ public class ASTLess extends ConditionNo
             return Boolean.FALSE;
         }
 
-        Comparable c1 = ConversionUtil.toComparable(evaluateChild(0, o));
-        if (c1 == null) {
-            return Boolean.FALSE;
-        }
-
-        Comparable c2 = ConversionUtil.toComparable(evaluateChild(1, o));
-        if (c2 == null) {
-            return Boolean.FALSE;
-        }
+        Object o1 = evaluateChild(0, o);
+        Object o2 = evaluateChild(1, o);
+        int diff = Evaluator.evaluator(o1).compare(o1, o2);
 
-        return c1.compareTo(c2) < 0 ? Boolean.TRUE : Boolean.FALSE;
+        return diff < 0 ? Boolean.TRUE : Boolean.FALSE;
     }
 
     /**

Modified: cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTLessOrEqual.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTLessOrEqual.java?rev=1510018&r1=1510017&r2=1510018&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTLessOrEqual.java
(original)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTLessOrEqual.java
Sat Aug  3 15:50:34 2013
@@ -20,7 +20,6 @@
 package org.apache.cayenne.exp.parser;
 
 import org.apache.cayenne.exp.Expression;
-import org.apache.cayenne.util.ConversionUtil;
 
 /**
  * "Less than or equal to" expression.
@@ -54,17 +53,11 @@ public class ASTLessOrEqual extends Cond
             return Boolean.FALSE;
         }
 
-        Comparable c1 = ConversionUtil.toComparable(evaluateChild(0, o));
-        if (c1 == null) {
-            return Boolean.FALSE;
-        }
-
-        Comparable c2 = ConversionUtil.toComparable(evaluateChild(1, o));
-        if (c2 == null) {
-            return Boolean.FALSE;
-        }
+        Object o1 = evaluateChild(0, o);
+        Object o2 = evaluateChild(1, o);
+        int diff = Evaluator.evaluator(o1).compare(o1, o2);
 
-        return c1.compareTo(c2) <= 0 ? Boolean.TRUE : Boolean.FALSE;
+        return diff <= 0 ? Boolean.TRUE : Boolean.FALSE;
     }
 
     /**

Modified: cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTNotBetween.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTNotBetween.java?rev=1510018&r1=1510017&r2=1510018&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTNotBetween.java
(original)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTNotBetween.java
Sat Aug  3 15:50:34 2013
@@ -17,11 +17,9 @@
  *  under the License.
  ****************************************************************/
 
-
 package org.apache.cayenne.exp.parser;
 
 import org.apache.cayenne.exp.Expression;
-import org.apache.cayenne.util.ConversionUtil;
 
 /**
  * "Not Between" expression.
@@ -51,24 +49,12 @@ public class ASTNotBetween extends Condi
             return Boolean.FALSE;
         }
 
-        Comparable c1 = ConversionUtil.toComparable(evaluateChild(0, o));
-
-        if (c1 == null) {
-            return Boolean.FALSE;
-        }
-
-        Comparable c2 = ConversionUtil.toComparable(evaluateChild(1, o));
-        if (c2 == null) {
-            return Boolean.FALSE;
-        }
-
-        Comparable c3 = ConversionUtil.toComparable(evaluateChild(2, o));
-        if (c3 == null) {
-            return Boolean.FALSE;
-        }
+        Object o1 = evaluateChild(0, o);
+        Object o2 = evaluateChild(1, o);
+        Object o3 = evaluateChild(2, o);
+        Evaluator e = Evaluator.evaluator(o1);
 
-        return c1.compareTo(c2) >= 0
-            && c1.compareTo(c3) <= 0 ? Boolean.FALSE : Boolean.TRUE;
+        return e.compare(o1, o2) >= 0 && e.compare(o1, o3) <= 0 ? Boolean.FALSE
: Boolean.TRUE;
     }
 
     /**

Modified: cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/util/ConversionUtil.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/util/ConversionUtil.java?rev=1510018&r1=1510017&r2=1510018&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/util/ConversionUtil.java
(original)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/util/ConversionUtil.java
Sat Aug  3 15:50:34 2013
@@ -113,6 +113,9 @@ public class ConversionUtil {
         else if (object instanceof Comparable) {
             return (Comparable) object;
         }
+        else if (object instanceof StringBuilder) {
+            return object.toString();
+        }
         else if (object instanceof StringBuffer) {
             return object.toString();
         }



Mime
View raw message