background image

Schema-Derived JAXB Classes

<< JAXB Schema Generator Option | Schema-to-Java Bindings >>
<< JAXB Schema Generator Option | Schema-to-Java Bindings >>

Schema-Derived JAXB Classes

TABLE 17­12
Schema-Derived JAXB Classes in the Basic Examples
(Continued)
Class
Description
primer/po/ObjectFactory.java
Public class extending
com.sun.xml.bind.DefaultJAXBContextImpl
; used to
create instances of specified interfaces. For example, the
ObjectFactory createComment()
method instantiates a
Comment
object.
primer/po/PurchaseOrder.java
Public interface extending javax.xml.bind.Element,
and PurchaseOrderType; binds to the global schema
element
named PurchaseOrder.
primer/po/PurchaseOrderType.java
Public interface that binds to the schema complexType
named PurchaseOrderType.
primer/po/USAddress.java
Public interface that binds to the schema complexType
named USAddress.
primer/po/impl/CommentImpl.java
Implementation of Comment.java
primer/po/impl/ItemsImpl.java
Implementation of Items.java
primer/po/impl/PurchaseOrderImpl.java
Implementation of PurchaseOrder.java
primer/po/impl/PurchaseOrderTypeImpl.java
Implementation of PurchaseOrderType.java
primer/po/impl/USAddressImpl.java
Implementation of USAddress.java
Note ­
You should never directly use the generated implementation classes (*Impl.java in the
packagename/impl/ directory). These classes cannot be referenced directly because the class
names in this directory are not standardized by the JAXB specification. The ObjectFactory
method is the only portable means to create an instance of a schema-derived interface. There is
also an ObjectFactory.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 in
Table 17­13
. .
TABLE 17­13
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
JAXB Examples
The Java EE 5 Tutorial · September 2007
506