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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Java</strong>-to-Schema Examples<br />

540<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

In the default HashMap schema, key and value are both elements and are of data type anyType.<br />

<strong>The</strong> XML content will look like this:<br />

<br />

<br />

9027<br />

glasstop stove in black<br />

<br />

<br />

288<br />

wooden spoon<br />

<br />

<br />

To resolve this issue, the example uses two <strong>Java</strong> classes, PurchaseList and PartEntry, that<br />

reflect the needed schema format for unmarshalling/marshalling the content. <strong>The</strong> XML schema<br />

generated for these classes is as follows:<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

Class AdapterPurchaseListToHashMap implements the XmlAdapter interface. In class<br />

KitchenWorldBasket, the @Xml<strong>Java</strong>TypeAdapter annotation is used to pair<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!