Class XMLUnionField

All Implemented Interfaces:
Serializable, Cloneable, CoreField, Field<XMLConversionManager,NamespaceResolver>, UnionField<XMLConversionManager,NamespaceResolver>

public class XMLUnionField extends XMLField implements UnionField<XMLConversionManager,NamespaceResolver>

Subclass of XMLField for fields that are mapped to unions. Maintains a list of schema types instead of just one single schema type. Schema types can be added using the addSchemaType api. XMLConstants has a list of useful constants including a list of QNames for built-in schema types that can be used when adding schema types.

When reading and writing an element that is mapped with an XMLUnionField, a conversion to each of the schema types on the field (in the order they are specified ) is tried until a conversion is successful. The java type to convert to is based on the list of schema type to java conversion pairs specified on the field. These conversion pairs can be modified using the addXMLConversion api.

Code Sample
In this example the age field could be a date or an int.
XMLUnionField field = new XMLUnionField("age/text()");
field.addSchemaType(XMLConstants.DATE_QNAME);
field.addSchemaType(XMLConstants.INT_QNAME)

See Also: