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: [BeanUtils] auto construction and expansion of array
Date Thu, 27 Mar 2003 23:09:36 GMT
hello

i can see the usefulness of this code in some particular cases but i'm not 
very keen on it's inclusion in a general library (at least in it's current 
form).

arrays are dealt with by beanutils as part of more general indexed 
properties. PropertyUtils.setIndexedProperty allows entries in arrays to 
be set but does not expand the arrays. i think that allowing 
setIndexedProperty to expand arrays would risk confusion: for example, 
would you only expand the array if the index was one more than the current 
size - or would you add sufficient null entries?

on the other hand, this is IMHO too specific an issue to warrant the 
addition of an extra method into what is a general library.

of course, other people might feel differently.

- robert

On Thursday, March 20, 2003, at 09:20 AM, Mingfai Ma wrote:

> hi,
>
> I wonder whether you think it is a useful feature for BeanUtils
> (PropertyUtils) to do the following:
>
> (when setting a value, detect if the property is an array)
> 1. if the property is an array and is not constructed and initialized,
> construct one and have the new value add to the last slot.
>
> 2. if the array property is not null, check if there is any empty slot (
> null). set value to the last empty slot.
>
> 3. if the array property is not null, and is full, expand it by one and 
> set
> the value to the last (expanded) slot.
>
> Attached is the code that does this at the outside of BeanUtils. If you
> think it's useful, I can clean the code up and put into the PropertyUtils
> and submit a patch.
>
> I guess it may be a bad practice to do so, and there will be performance
> drawback. So, a flag should be there to enable the feature.
>
> (btw, let me know if such method is existed already!)
>
> Regards,
> mingfai
>
>
>  ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org


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


Mime
View raw message