users@jaxb.java.net

Re: jaxb and upcasting

From: <dev_at_samizdatdigital.org>
Date: Wed, 23 Jun 2004 16:24:38 -0700

thanks. i'd certainly be interested in something along the lines of the
answer to the first solution.

for the second, i'll start playing around with turning on type
substitution. that sounds like it may be a good way to do what i need.
the copy constructor idea sounds okay, but i'll see if the existing
machinery works. the other option (the copy constructor) would be
suitable as well (my guess is that an implementation would be along the
lines of a recursive reflective walk? or maybe the xjc actually
produces code with all of that statically built in?).

jon

On Jun 23, 2004, at 4:08 PM, Kohsuke Kawaguchi wrote:

>
> 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
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net