Justin,

I tried to move a patch forward to CompareFilterImpl, but its changed too much on trunk. You were the one who made the changes so I'm sending the patch to you because I dont know what the new implementation does.

It appears to still have the same bug if one or both of the objs are null, I think you can just add it to the top of the compare() function.


Also, the code has:

else {
           //both numbers, make double
           leftObj = new Double(((Number)leftObj).doubleValue());
           rightObj = new Double(((Number)rightObj).doubleValue());
       }
return leftObj.compareTo(rightObj);

You're creating two Double objects FOR EACH COMPARISON - you should probably use Double.compare(double,double).

dave

Here's the 2.2 patch:
===================================================================
--- org/geotools/filter/CompareFilterImpl.java    (revision 19040)
+++ org/geotools/filter/CompareFilterImpl.java    (working copy)
@@ -147,22 +147,28 @@
     *         filter.
     */
    public boolean contains(Feature feature) {
-        LOGGER.entering("CompareFilter", "contains");
+
-        // Checks for error condition
-        if ((leftValue == null) | (rightValue == null)) {
-            LOGGER.finer("one value has not been set");
-
-            return false;
-        }
-
        try {
            // Non-math comparison
+ + Object leftObj = leftValue.getValue(feature);
+            Object rightObj = rightValue.getValue(feature);
+ + if ( (leftObj == null) || (rightObj ==null) )
+            {
+                 if ( leftObj ==rightObj ) //both null
+ return (filterType == COMPARE_EQUALS); // all others are false + return (filterType == COMPARE_NOT_EQUALS); // null <op> value --> false and value <op> value --> false + // except for null != value
+            }
+
-    if (!(leftValue.getValue(feature) instanceof Number &&
-          rightValue.getValue(feature) instanceof Number))
+    if (!(leftObj instanceof Number &&     (rightObj instanceof Number)))
    {
+ + if (LOGGER.isLoggable(Level.FINEST))
        {
            LOGGER.finest("is equals thingy");
@@ -172,8 +178,7 @@
                + rightValue.getValue(feature).getClass().toString());
        }
- Object leftObj = leftValue.getValue(feature);
-            Object rightObj = rightValue.getValue(feature);
+
if (!(leftObj.getClass() == rightObj.getClass())) //both Number case handled above
            {
@@ -246,10 +251,8 @@
} }
            // Math comparisons
-            double leftResult = ((Number) leftValue.getValue(feature))
-                .doubleValue();
-            double rightResult = ((Number) rightValue.getValue(feature))
-                .doubleValue();
+            double leftResult = ((Number) leftObj).doubleValue();
+            double rightResult = ((Number) rightObj).doubleValue();


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Geotools-devel mailing list
Geotools-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to