users@jaxb.java.net

Re: jaxb and upcasting

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Wed, 23 Jun 2004 16:08:01 -0700

There are two issues. One is when you got a type object, how do you
write it as a whole XML. The other is when you got an element object,
how do you get the corresponding type object.

For the first problem, I think I can relatively easily fix this by
adding the generic element wrapper as a part of the impl.runtime package.
This can be used to avoid the problem. It is still a hack, but I guess
it's far better than nothing.

For the latter problem, you can turn on the type substitution support,
which causes XJC to produce one class for type, and another class for
the element, with has-A relation. So you can do:

    elementInstance.getValueObject();

to get the type instance.

I think another idea is to have a copy constructor of the form "FooType
createFooType(FooType)" on ObjectFactory or somwhere, so that you can
say:

    createFooType(aFooElementInstance);

If enough people are interested in this, I for one would be very happy
to consider doing this for JAXB 1.0.x


And just to make sure, the JAXB EG is fully aware of this issue, and I
think we will be able to handle both of them quite nicely in 2.0.


regards,
--
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net