users@jaxb.java.net

Re: javaType generates JAXBElement wrapper

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Mon, 06 Nov 2006 11:48:51 -0800

Petteri Stenius wrote:
> Hi,
>
> I think the following behavior is strange.
>
> My schema fragment looks like this:
>
> <complexType name="Document">
> <sequence>
> <element ref="my:Property" maxOccurs="unbounded"/>
> </sequence>
> </complexType>
>
> <element name="Property" type="anyURI"/>
>
> As expected the schema generates an accessor method as follows:
>
> List<String> getProperty();
>
> However, because I'd like to substitute java.net.URI for anyURI I added the following to globalBindings:
>
> <jaxb:javaType name="java.net.URI" xmlType="anyURI"/>
>
> The surpise is that after this the accessor method looks like this:
>
> List<JAXBElement<URI>> getProperty();
>
> Why did the JAXBElement wrapper appear here?

Because if you place @XmlAdapter on the List<String> getProperty(), it
will try to convert the whole List by your adapter, and not individually.

That was the original reason anyway, but since then I realized if the RI
checks the type of Adapter, it might be able to determine whether to
adapt individual items or to adapt the whole list.

So feel free to file this as a bug.

-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com