Use an adapter that implements {@link XmlAdapter} for custom marshaling.
Usage:
The @XmlJavaTypeAdapter annotation can be used with the
following program elements:
- a JavaBean property
- field
- parameter
- package
- from within {@link XmlJavaTypeAdapters}
When @XmlJavaTypeAdapter annotation is defined on a
class, it applies to all references to the class.
When @XmlJavaTypeAdapter annotation is defined at the
package level it applies to all references from within the package
to @XmlJavaTypeAdapter.type().
When @XmlJavaTypeAdapter annotation is defined on the
field, property or parameter, then the annotation applies to the
field, property or the parameter only.
A @XmlJavaTypeAdapter annotation on a field, property
or parameter overrides the @XmlJavaTypeAdapter annotation
associated with the class being referenced by the field, property
or parameter.
A @XmlJavaTypeAdapter annotation on a class overrides
the @XmlJavaTypeAdapter annotation specified at the
package level for that class.
This annotation can be used with the following other annotations:
{@link XmlElement}, {@link XmlAttribute}, {@link XmlElementRef},
{@link XmlElementRefs}, {@link XmlAnyElement}. This can also be
used at the package level with the following annotations:
{@link XmlAccessorType}, {@link XmlSchema}, {@link XmlSchemaType},
{@link XmlSchemaTypes}.
Example: See example in {@link XmlAdapter} |