commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robert burrell donkin <robertburrelldon...@blueyonder.co.uk>
Subject Re: Posssible bug in Betwixt alpha
Date Thu, 14 Aug 2003 20:36:24 GMT
just to let people know...

i committed some code a little while ago which (hopefully) solves this 
problem. i've added a new strategy interface called ObjectStringConverter 
which performs object to string and string to object conversions.

the new default implementation (of this stategy) delegates to ConvertUtils 
for all class except java.util.Date (which are not also java.sql.Date, 
java.sql.Time or java.sql.Timestamp subclasses). java.util.Date are read 
and written using the toString() pattern. the upshot of this is that the 
default behaviour (with no ConvertUtil customization) now supports round 
tripping in the same format as previously.

a pure ConvertUtils implementations is available for those who want to use 
ConvertUtils exclusively.

i've also made sure that conversions happen both on input and output so 
that round tripping now works with these values.

i plan to write up these new features in the documentation very soon.

- robert

On Wednesday, July 23, 2003, at 11:50 AM, James Strachan wrote:

> Betwixt uses BeanUtils's ConverterUtils to do type conversions. You could 
> always register your own special converter object to handle the 
> conversion of String -> Date. Though I would have throught this worked 
> out of the box as I thought java.util.Date was supported.
>
> Any chance you could create a little test case of a bean & some XML that 
> doesn't work correctly and we can add it to the JUnit test cases & then 
> fix the problem.
>
> BTW your bean is following the Java beans property naming rules? i.e. one 
> getter & one setter with the same type?
>
>
> On Wednesday, July 23, 2003, at 12:01  am, Ujjwala Kulkarni wrote:
>
>> Hi ,
>>
>>  
>>
>> I guess , when user calls method beanReader.parse(file) , the  ‘update’ 
>> of class org.apache.commons.betwixt.expression.MethodUpdater  gets 
>> called.
>>
>>  
>>
>> I observed that if the data types are java.util.Date , int the 
>> attributes are not getting converted to the required data type and hence 
>> I get the InvalidArgumentExcetion as the default attribute type passed 
>> is ‘String’
>>
>>  
>>
>> If the date is java.sql.Date then there is no problem but if it is java.
>> util.Date type then I get this exception. One possible cause is that 
>> these data types do not have constructors accepting String as only 
>> argument.
>>
>>  
>>
>> e.g java.util.Date  has deprecated new Date(String) constructor.
>>
>> And the Interger can not be converted to int like  new int(String)  the 
>> code
>>
>>  
>>
>> “newValue = ConvertUtils.convert( (String) newValue, valueType );”  will 
>> always fail to convert to int or java.util.Date.
>>
>>  
>>
>> Attaching the log file where I modified MethodUpdater and the log file I 
>> got. In theMethodUpdater , I have put some statements with ‘UJ’ so you 
>> will see the log has those debug statements.
>>
>>  
>>
>> Thanks
>>
>> Ujjwala
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
> James
> -------
> http://radio.weblogs.com/0112098/


Mime
View raw message