Hi Andrea,

Your hitting on some definite issues with the api... and ones i am 
ashamed to say i have hacked around in the past :(. So here is what I 
think is needed:

1. A way to do only *safe* vs *lax* conversions
2. A way to prioritize or sort factories

So i would recommend the following:

1. Add a method to Converter"

boolean isSafe();

Then we also add an additional method to Converters called convert( ..., 
boolean safe ), which would only allow safe coverters to execute.

2. Add a method to ConverterFactory:

int getPriority();

And then sort on it when the converter factories are loaded.

What do folks think?

-Justin

Andrea Aime wrote:
> Andrea Aime ha scritto:
>> Andrea Aime ha scritto:
>>> Andrea Aime ha scritto:
>>>> 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
>> Here is another funny one (result running with jdk6):
>> System.out.println(Converters.convert("12e2", Long.class));
>> System.out.println(Converters.convert("12e2", Double.class));
>> 12
>> 1200
> 
> Hmmm. The 0 is due to a bug in the commons based converter
> (http://jira.codehaus.org/browse/GEOT-1808) whilst the
> other issues are there because of how NumericConverter
> behaves.
> 
> First question, given that the commons one is already able to work with
> numbers, why do we have the NumericConverter around?
> The issue in NumericConverter seems to be, anyways, that
> the fractional part is shaved off without mercy if the
> target in a integral number class... and it seems intended
> behaviour as well... which makes me wonder why
> 
> 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
> 
> !DSPAM:4007,4821b9b7165691096210785!
> 


-- 
Justin Deoliveira
The Open Planning Project
[EMAIL PROTECTED]

-------------------------------------------------------------------------
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