commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Frank W. Zammetti" <fzli...@omnytex.com>
Subject Re: [BeanUtils] Handling array creation?
Date Wed, 07 Sep 2005 20:44:48 GMT
I explained in another reply, but it's worth replying directly here...

The use case is that I'm dynamically creating instances of myBean based 
on a configuration file... this is part of the DependencyFilter I added 
to Jave Web Parts in the past few days.  It already handles simple 
properties, Maps and Lists with no problem, but arrays seem a bit 
trickier...

The thing that is making it trickier, unless I'm missing something 
simple (which is entirely possible!) is that say I read in the config 
file and find that there are 10 items to be added to a given array field 
in byBean... I don't want myBean to have to know before-hand how big the 
  array will be, nor do I want to have to arbitrarily set some high 
value.  So, I need to be able to dynamically create the array from 
OUTSIDE myBean based on the number of items found in the config file.

Since myArray is private in myBean as per my example, I can't simply 
access the field directly as I showed in the example.  Hence my question :)

Hope that makes some sense...

Frank

Niall Pemberton wrote:
> LazyDynaBean does this, but I guess you don't want DynaBeans.
> 
> Whats the circumstance of you wanting to do this dynamically - rather than
> just initializing it as you are in your example?
> 
> Niall
> 
> ----- Original Message ----- 
> From: "Frank W. Zammetti" <fzlists@omnytex.com>
> Sent: Wednesday, September 07, 2005 7:55 PM
> 
> 
> 
>>I kind of assume this isn't possible based on what I've seen, but figured
>>I'd ask none the less...
>>
>>Is it possible with BeanUtils (or otherwise) to create a new array as a
>>member of a bean?  What I mean is, if I have this bean:
>>
>>class myBean {
>>  private String[] myArray;
>>}
>>
>>Can I do the equivalent of this:
>>
>>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.
>>Thanks!
>>
>>-- 
>>Frank W. Zammetti
>>Founder and Chief Software Architect
>>Omnytex Technologies
>>http://www.omnytex.com
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
>>
>>
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 
> 
> 
> 

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com


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


Mime
View raw message