commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Frank W. Zammetti" <>
Subject Re: [BeanUtils] Handling array creation?
Date Wed, 07 Sep 2005 20:44:51 GMT
Thomas Dudziak wrote:
>>class mainClass {
>>  myBean b = new myBean();
>>  b.myArray = new String[5];
>>Obviously that's not valid, but pretend it would work, I need to write
>>*real* code that *will* work to do the equivalent of that.  I haven't seen
>>anything in BeanUtils that would do it, hoping I'm missing something.
> Could you perhaps explain what is the problem with the above ? Perhaps
> you could provide some (pseudo, hypothetical) code using BeanUtils
> that shows how you would do what you want to do ?

I can certainly explain why the above isn't valid... myArray is private 
in myBean, so I can't do the above because I simply don't have access to 
that field.  If it was public then the above would work fine and I 
wouldn't have a question :)

The use case here is specifically for the DependencyFilter I add in Java 
Web Parts... basically, I'm instantiating a class based on a config 
file, and then configuring it (rudimentary IoC)... It already handles 
simple properties, Lists and Maps no problem, but arrays seemingly are a 
little trickier (and maybe I'm wrong about that to begin with) because 
of one thing I want to do: I don't want to force the class to have to 
create the array itself.  I want to be able to have a list of values in 
the config file and create the array based on the number of elements, 
which of course could vary.  So, I won't know the array size until the 
object is created.

Does that make sense?

> Tom


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message