users@jaxb.java.net

Re: Specifying Interfaces that generated classes extend/implement

From: Marek Malowidzki <maom_onet_at_poczta.onet.pl>
Date: Thu, 06 Mar 2003 12:35:38 +0100

> Erik Ostermueller wrote:
> > So, is it true jaxb does not code generate
> > custom 'implements' statements?
> >
>
> I don't see how it could. Obviously, the generated interfaces can't implement
> other interfaces. We could add 'implements' on the generated impl classes,
but
> the code wouldn't compile because the implementation of those methods would be
> missing.

Not necessarily! Sometimes we would like to group some methods from the
generated interfaces into other interfaces (custom ones). For example, assume
that we have a number of XML elements with a set of the same attributes. For
example, multiple XML elements have both 'width' and 'height' attributes. From
the point of view of XML, these elements are completely separate, but in Java
they could extend some interface. We would like to move these attributes to a
separate interface to be able to apply Java code to these interfaces. For
example, to have a 'Size' Java interface with the 'getWidth' and 'getHeight'
methods.

It would be also possible to build this hierarchy in XML. I do not remember now
the details, but after I had a look at this possibility I discovered some
problems (does JAXB support XML elements extensions?). Moreover, it is possible
that one cannot change XML (for example, it comes from multiple sources and was
generated by someone else, etc.).

I had such a problem after I had migrated from the early access release, which
enabled such features. I finally found a workaround, which was described in one
of my earlier posts.

Marek