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>The</strong> default content order for @XmlType.propOrder is {} or {""}, not active. In such cases, the<br />

active @XmlAccessorOrder annotation takes precedence. When class content order is specified<br />

by the @XmlType.propOrder annotation, it takes precedence over any active<br />

@XmlAccessorOrder annotation on the class or package. If the @XmlAccessorOrder and<br />

@XmlType.propOrder(A, B, ...) annotations are specified on a class, the propOrder always<br />

takes precedence regardless of the order of the annotation statements. For example, in the code<br />

below, the @XmlAccessorOrder annotation precedes the @XmlType.propOrder annotation.<br />

@XmlAccessorOrder(AccessorOrder.ALPHABETICAL)<br />

@XmlType(propOrder={"name", "city"})<br />

public class USAddress {<br />

.<br />

.<br />

public String getCity() {return city;}<br />

public void setCity(String city) {this.city = city;}<br />

public String getName() {return name;}<br />

public void setName(String name) {this.name = name;}<br />

.<br />

.<br />

}<br />

In the code below, the @XmlType.propOrder annotation precedes the @XmlAccessorOrder<br />

annotation.<br />

@XmlType(propOrder={"name", "city"})<br />

@XmlAccessorOrder(AccessorOrder.ALPHABETICAL)<br />

public class USAddress {<br />

.<br />

.<br />

public String getCity() {return city;}<br />

public void setCity(String city) {this.city = city;}<br />

public String getName() {return name;}<br />

public void setName(String name) {this.name = name;}<br />

.<br />

.<br />

}<br />

In both scenarios, propOrder takes precedence and the identical schema content shown below<br />

will be generated.<br />

<br />

<br />

<br />

<br />

<br />

<br />

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

Chapter 17 • Binding between XML Schema and <strong>Java</strong> Classes 537

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

Saved successfully!

Ooh no, something went wrong!