The Java EE 5 Tutorial

Property Binding Declarations

Of particular interest here is the generateIsSetMethod customization, which causes two additional property methods, isSetQuantity and unsetQuantity, to be generated. These methods enable a client application to distinguish between schema default values and values occurring explicitly within an instance document.

For example, in po.xsd:

<xsd:complexType name="Items">
      <xsd:element name="item" minOccurs="1" maxOccurs="unbounded">
            <xsd:element name="productName" type="xsd:string"/>
            <xsd:element name="quantity" default="10">
                  <jxb:property generateIsSetMethod="true"/>

The @generateIsSetMethod applies to the quantity element, which is bound to a property within the Items.ItemType interface. unsetQuantity and isSetQuantity methods are generated in the Items.ItemType interface.