users@jaxb.java.net

Re: determine the type of elements in a list property

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Fri, 22 Jun 2007 16:01:19 -0700

Hunor Bartha wrote:
> Hello everybody,
>
> it seems that my jaxb-reflection related questions are rather unpopular
> around here, but i give it a try again.

No, it's just that there are not enough of us to answer questions, and
reflection related questions have even less people who can answer
questions. So it just took time. My apologies.

> I have a jaxb mapped class that
> contains a property that is a list (corresponds to an element with
> maxOccurs="unbounded"). My question is that if I want to add elements to
> this list at runtime, is there a way to determine the type of elements
> that this contains?

Yes. Such property is represented as ElementPropertyInfo, and its
getTypes() method will return a set of TypeRefs that represent what are
allowed.

> My code is implemented in such way to be able to
> handle any jaxb mapped object so I don't have the name of the methods,
> or any specific jaxb object related information hard-coded (but i do
> have the jaxb2-reflection library ;)). I need the type of the elements
> in the list to be able to create new instances of that type.
>
> Thanks,
>
> hunor
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>


-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com