commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Benson <gudnabr...@yahoo.com>
Subject Re: [Beanutils] Determine type of bean field
Date Thu, 01 Jun 2006 20:58:38 GMT
--- Craig McClanahan <craigmcc@apache.org> wrote:

> On 6/1/06, Frank W. Zammetti <fzlists@omnytex.com>
> wrote:
[SNIP]
> > Ok, I'm with you so far... but what if you don't
> know the type of the
> > target array until runtime?  I need to dynamically
> determine the element
> > type of the target array, then construct a new
> array instance to pass to
> > toArray() here.  I'm messing around right now, but
> haven't stumbled on the
> > right answer yet...
> 
> 
> I imagine you would have to synthesize the class for
> "array of Foo", and
> then ask it for a newInstance() to create the
> calling argument ... check
> methods in the java.util.Arrays class for useful
> ways to do that.
> 
> Of course, you won't be able to cast the actual
> result instance (defaults to
> Object[]) if you don't know the type at compile
> time.
> 
> Craig

Does he really need to be able to cast in this
instance, since the PropertyUtilsBean would just be
attempting to set an Object?  i.e. wouldn't the
runtime type be enough in this case, and casting would
be more relevant when you want to cast to an array for
the purposes of e.g. implementing a particular API?

-Matt

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


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.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