First off, apologies posting this here. I can't seem
to gain access to any Geotools site to report this
normally.

Essentially the BetweenFilterImpl compare method is
does not appear to be working correctly.

<ogc:Filter>
<ogc:PropertyIsBetween>                 
<ogc:PropertyName>Ccode</ogc:PropertyName>      
<ogc:LowerBoundary><ogc:Literal>40</ogc:Literal></ogc:LowerBoundary>
<ogc:UpperBoundary><ogc:Literal>50</ogc:Literal></ogc:UpperBoundary>
</ogc:PropertyIsBetween>
</ogc:Filter>

In the example above 'Ccode' is a numeric value
between 1 and 100. The BetweenFilterImpl.compare
method does not correctly reassign this value from a
String to a numeric value. Condition checking always
results in an IllegalArgumentException being thrown by
the object if the middle attribute is numeric.

A possible fix is given below ... but essentially if
both left and right values are numerics the middle
value should be treated as a numeric. 

... code at approx line 98 ...
if (leftObj instanceof Number &&
  //middleObj instanceof Number && //problem condition
  rightObj instanceof Number) {
  //handle for NumberFormatException
  try {
   double mid = Double.parseDouble((String)middleObj);
   double left = ((Number)leftObj).doubleValue();
   double right = ((Number)rightObj).doubleValue();
   //double mid = ((Number)middleObj).doubleValue();
   return (left <= mid) && (right >= mid);
  } catch (NumberFormatException e) {
   System.out.println("Cannot handle character
attribute!");
   //e.printStackTrace();
     return false;
  }
...

regards,

Ed


                
___________________________________________________________ 
To help you stay safe and secure online, we've developed the all new Yahoo! 
Security Centre. http://uk.security.yahoo.com


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to