commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niall Pemberton <niall.pember...@gmail.com>
Subject Re: [beanutils] BeanUtilsBean#setProperty() behaviour in 1.7 and 1.8
Date Wed, 09 Mar 2011 23:37:54 GMT
2011/3/7 Björn Moritz <bjoern.moritz@gmail.com>:
> Hello,
>
> is there a reason for BeanUtilsBean#setProperty() in line 968 not
> using the PropertyType of the current PropertyDescriptor as the type
> of class to convert to, but instead the class of the value to be
> converted?
> Until beanutils 1.7 a String array was converted to a string using the
> first element of the array; since 1.8 the string array is converted to
> a string using the toString method of the array (as the destination
> type is now an array type).
> Why can't we use the property descriptor for these mapped properties, too?

BeanUtils (uniquely) has the concept of a MappedPropertyDescriptor
like the IndexedPropertyDescriptor, so that if you have acessor
methods in your bean with a key parameter, then it assumes it is
accessing an underlying Map. In that scenario it does indeed use the
descriptor to determine the type. However if it has  a Map property
(i.e. has methods that set/return a Map) then there is no way to
determine the type. By the time it reaches the line number you quote,
then its in the later scenario and the type can't be determined -
since the descriptor type should be a Map.

Niall


> Regards,
>
> Björn
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message