users@jaxb.java.net

Re: How to use subclasses of JAXB created classes

From: Aleksei Valikov <valikov_at_gmx.net>
Date: Thu, 14 Jun 2007 16:23:43 +0200

Hi.

  I have a bunch of JAXB created classes, FooData, BarData, etc. Using the
> "Strategy pattern" I want each class to have a method, pair(), that will
> return a list of key/value pairs.
>
> My first thought was to create classes, such as SuperFooData,
> SuperBarData, etc, which extended FooData, BarData and implemented
> Pairable. The problem with this approach, is that it is fairly difficult to
> marshall data from XML into a subclass.


Take a look at "copyable" plugin from jaxb2-commons/basic. It is capable of
generating method like:

    public Object copyTo(Object target);

You could the copy data from classes to subclasses.

Bye.
/lexi