Wednesday, October 31, 2007

Generate is property set methods in JAXB objects

JAXB "is property set" method object

Defining a default value in the schema does not come through as a default value in the generated objects. This could be worked around if you could check for when a field has been explicitly set in the XML (as opposed the value being returned by the get or is) method being the default).

Along the lines of past post - Getting xs:any as DOM object

You simply add another custom binding property:
    <jaxb:property generateIsSetMethod="true"/>

This post has the snippet: How do you pick up default values from XSD/JAXB
Reasonable summary of Customizing JAXB Bindings (though not that easy to read): Customizing JAXB Bindings.