10.12.2012 Views

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Customizing JAXB Bindings<br />

■ If typesafeEnumBase is set to xsd:string, it would be a global way to specify that all simple<br />

type definitions deriving directly or indirectly from xsd:string and having enumeration<br />

facets should be bound by default to a typesafe enum.IftypesafeEnumBase is set to an<br />

empty string, "",nosimple type definitions would ever be bound to a typesafe enum class<br />

by default. <strong>The</strong> value of typesafeEnumBase can be any atomic simple type definition except<br />

xsd:boolean and both binary types.<br />

■ <strong>The</strong> JAXB implementation does not support the enableFailFastCheck attribute.<br />

Note – Using typesafe enum classes enables you to map schema enumeration values to <strong>Java</strong><br />

constants, which in turn makes it possible to do compares on <strong>Java</strong> constants rather than<br />

string values.<br />

Schema Binding Declarations<br />

<strong>The</strong> following code shows the schema binding declarations in po.xsd:<br />

<br />

<br />

<br />

Package level documentation for generated package primer.myPo.]]><br />

<br />

<br />

<br />

<br />

<br />

<br />

526<br />

■ specifies the primer.myPo as the package in which<br />

the schema-derived classes should be generated.<br />

■ specifies that all generated <strong>Java</strong> element interfaces should have<br />

Element appended to the generated names by default. For example, when the JAXB<br />

compiler is run against this schema, the element interfaces CommentElement and<br />

PurchaseOrderElement will be generated. By contrast, without this customization, the<br />

default binding would instead generate Comment and PurchaseOrder.<br />

This customization is useful if a schema uses the same name in different symbol spaces; for<br />

example, in global element and type definitions. In such cases, this customization enables<br />

you to resolve the collision with one declaration rather than having to individually resolve<br />

each collision with a separate binding declaration.<br />

■ specifies customized <strong>Java</strong>doc tool annotations for the primer.myPo<br />

package. Note that, unlike the declarations at the class level, below, the opening<br />

and closing tags must be included when the declaration is made at the<br />

package level.<br />

<strong>The</strong> <strong>Java</strong> <strong>EE</strong> 5<strong>Tutorial</strong> • June 2010

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!