Hi,
I've been looking a little more in our converters usage and
I believe I'm finding quite a few issues.

The first one is due to the following converters behaviour.
The following snippet:
System.out.println(Converters.convert("1002.5", Integer.class));
System.out.println(Converters.convert("1002.0", Long.class));
results in the following output:
1002
0

So the integer converter is actually casting the data, while the
long one is giving up but is not returning nor null nor the 1002
that I would expect.
Imho the correct result of the above should be:
null (not an integer!)
new Long(1002) (yes, the decimal part is 0 no?)

That is, make a conversion when it makes sense, but do not try
to force a square peg in a round hole. Opinions?


The second problem I'm seeing is with the following filter:
             <ogc:Filter>
                <ogc:PropertyIsEqualTo>
<ogc:PropertyName>sf:longProperty</ogc:PropertyName>
                   <ogc:Sub>
                      <ogc:PropertyName>sf:intProperty</ogc:PropertyName>
                      <ogc:Literal>149.98</ogc:Literal>
                   </ogc:Sub>
                </ogc:PropertyIsEqualTo>
             </ogc:Filter>
          </wfs:Query>

In this case FilterToSql is asking the literal visit to perform
a cast towards Long. Why? Because the PropertyIsEqualTo is
getting the target context from the the attribute type (Long)
and it's passing it down to the Sub, which in turn passes
it down to the literal, which, hacks aside, tries to coax
149.98 to a long ending up with a 0. Erk!
But the same would happen with a much simpler

<ogc:PropertyIsEqualTo>
   <ogc:PropertyName>sf:longProperty</ogc:PropertyName>
   <ogc:Literal>149.98</ogc:Literal>
</ogc:PropertyIsEqualTo>

The problem I see here is that the context should be considered
as a wish, but not as an order, that is, if you can convert it
to a Long that's nice and all, but don't try to force it to
a Long if it's not. If the longProperty is a long, the test should
always legitimately fail. With the current implementation, the
test will actually succeed if longProperty is 0, and fail for
the wrong reason if it's not.

Unfortunately, this calls for picky converters, not for the
lax behaviour we're seeing now.

Long story short, is it ok if I try to fix the converters to avoid
this silly outputs?

Cheers
Andrea


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to