Java Reference
In-Depth Information
@XmlElement(required=true)
protected String zip;
@XmlElement(required=true)
protected String country;
public Address() { }
// Getter and setter methods
// ...
}
The @XmlRootElement(name= address ) annotation maps this class to the ad-
dress XML element. The @XmlAccessorType(XmlAccessType.FIELD) an-
notation specifies that all the fields of this class are bound to XML by default. The @Xm-
lElement(required=true) annotation specifies that an element must be present in
the XML representation.
The following class represents a customer:
@XmlRootElement(name="customer")
@XmlAccessorType(XmlAccessType.FIELD)
public class Customer {
@XmlAttribute(required=true)
protected int id;
@XmlElement(required=true)
protected String firstname;
@XmlElement(required=true)
protected String lastname;
@XmlElement(required=true)
protected Address address;
@XmlElement(required=true)
protected String email;
@XmlElement (required=true)
protected String phone;
public Customer() { }
// Getter and setter methods
Search WWH ::




Custom Search