background image

JAXB Classes in the Basic Examples

<< About the Schema-to-Java Bindings | Schema-to-Java Bindings Examples >>
<< About the Schema-to-Java Bindings | Schema-to-Java Bindings Examples >>
20
U
SING
JAXB
Note: You should never directly use the generated implementation classes--that is,
*Impl.java
in the
<packagename>/impl
directory. These classes are not directly
referenceable because the class names in this directory are not standardized by the
JAXB specification. The
ObjectFactory
method is the only portable means to cre-
ate an instance of a schema-derived interface. There is also an
ObjectFac-
tory.newInstance(Class JAXBinterface)
method that enables you to create
instances of interfaces.
These classes and their specific bindings to the source XML schema for the basic
examples are described below.
primer/po/impl/
PurchaseOrderType-
Impl.java
Implementation of
PurchaseOrderType.java
primer/po/impl/
USAddressImpl.java
Implementation of
USAddress.java
Table 3­7 Schema-to-Java Bindings for the Basic Examples
XML Schema
JAXB Binding
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="purchaseOrder" type="PurchaseOrderType"/>
PurchaseOrder.java
<xsd:element name="comment" type="xsd:string"/>
Comment.java
<xsd:complexType name="PurchaseOrderType">
<xsd:sequence>
<xsd:element name="shipTo" type="USAddress"/>
<xsd:element name="billTo" type="USAddress"/>
<xsd:element ref="comment" minOccurs="0"/>
<xsd:element name="items" type="Items"/>
</xsd:sequence>
<xsd:attribute name="orderDate" type="xsd:date"/>
</xsd:complexType>
PurchaseOrder-
Type.java
Table 3­6 Schema-Derived JAXB Classes in the Basic Examples (Continued)
Class
Description