< prev index next >

src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlIDREF.java

Print this page

        

*** 36,51 **** * * <p> * To preserve referential integrity of an object graph across XML * serialization followed by a XML deserialization, requires an object * reference to be marshaled by reference or containment ! * appropriately. Annotations <tt>@XmlID</tt> and <tt>@XmlIDREF</tt> * together allow a customized mapping of a JavaBean property's * type by containment or reference. * * <p><b>Usage</b> </p> ! * The <tt>@XmlIDREF</tt> annotation can be used with the following * program elements: * <ul> * <li> a JavaBean property </li> * <li> non static, non transient field </li> * </ul> --- 36,51 ---- * * <p> * To preserve referential integrity of an object graph across XML * serialization followed by a XML deserialization, requires an object * reference to be marshaled by reference or containment ! * appropriately. Annotations {@code @XmlID} and {@code @XmlIDREF} * together allow a customized mapping of a JavaBean property's * type by containment or reference. * * <p><b>Usage</b> </p> ! * The {@code @XmlIDREF} annotation can be used with the following * program elements: * <ul> * <li> a JavaBean property </li> * <li> non static, non transient field </li> * </ul>
*** 56,80 **** * <p> The usage is subject to the following constraints: * <ul> * * <li> If the type of the field or property is a collection type, * then the collection item type must contain a property or ! * field annotated with <tt>@XmlID</tt>. </li> * <li> If the field or property is single valued, then the type of * the property or field must contain a property or field ! * annotated with <tt>@XmlID</tt>. * <p>Note: If the collection item type or the type of the * property (for non collection type) is java.lang.Object, then * the instance must contain a property/field annotated with ! * <tt>@XmlID</tt> attribute. * </li> * <li> This annotation can be used with the following annotations: * {@link XmlElement}, {@link XmlAttribute}, {@link XmlList}, * and {@link XmlElements}.</li> * * </ul> ! * <p><b>Example:</b> Map a JavaBean property to <tt>xs:IDREF</tt> * (i.e. by reference rather than by containment)</p> * <pre> * * //EXAMPLE: Code fragment * public class Shipping { --- 56,80 ---- * <p> The usage is subject to the following constraints: * <ul> * * <li> If the type of the field or property is a collection type, * then the collection item type must contain a property or ! * field annotated with {@code @XmlID}. </li> * <li> If the field or property is single valued, then the type of * the property or field must contain a property or field ! * annotated with {@code @XmlID}. * <p>Note: If the collection item type or the type of the * property (for non collection type) is java.lang.Object, then * the instance must contain a property/field annotated with ! * {@code @XmlID} attribute. * </li> * <li> This annotation can be used with the following annotations: * {@link XmlElement}, {@link XmlAttribute}, {@link XmlList}, * and {@link XmlElements}.</li> * * </ul> ! * <p><b>Example:</b> Map a JavaBean property to {@code xs:IDREF} * (i.e. by reference rather than by containment)</p> * <pre> * * //EXAMPLE: Code fragment * public class Shipping {
*** 99,130 **** * * <p><b>Example 2: </b> The following is a complete example of * containment versus reference. * * <pre> ! * // By default, Customer maps to complex type <tt>xs:Customer</tt> * public class Customer { * ! * // map JavaBean property type to <tt>xs:ID</tt> * @XmlID public String getCustomerID(); * public void setCustomerID(String id); * * // .... other properties not shown * } * * ! * // By default, Invoice maps to a complex type <tt>xs:Invoice</tt> * public class Invoice { * * // map by reference * @XmlIDREF public Customer getCustomer(); * public void setCustomer(Customer customer); * * // .... other properties not shown here * } * ! * // By default, Shipping maps to complex type <tt>xs:Shipping</tt> * public class Shipping { * * // map by reference * @XmlIDREF public Customer getCustomer(); * public void setCustomer(Customer customer); --- 99,130 ---- * * <p><b>Example 2: </b> The following is a complete example of * containment versus reference. * * <pre> ! * // By default, Customer maps to complex type {@code xs:Customer} * public class Customer { * ! * // map JavaBean property type to {@code xs:ID} * @XmlID public String getCustomerID(); * public void setCustomerID(String id); * * // .... other properties not shown * } * * ! * // By default, Invoice maps to a complex type {@code xs:Invoice} * public class Invoice { * * // map by reference * @XmlIDREF public Customer getCustomer(); * public void setCustomer(Customer customer); * * // .... other properties not shown here * } * ! * // By default, Shipping maps to complex type {@code xs:Shipping} * public class Shipping { * * // map by reference * @XmlIDREF public Customer getCustomer(); * public void setCustomer(Customer customer);
< prev index next >