1 /*
2 * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
66 * property (for non collection type) is java.lang.Object, then
67 * the instance must contain a property/field annotated with
68 * <tt>@XmlID</tt> attribute.
69 * </li>
70 * <li> This annotation can be used with the following annotations:
71 * {@link XmlElement}, {@link XmlAttribute}, {@link XmlList},
72 * and {@link XmlElements}.</li>
73 *
74 * </ul>
75 * <p><b>Example:</b> Map a JavaBean property to <tt>xs:IDREF</tt>
76 * (i.e. by reference rather than by containment)</p>
77 * <pre>
78 *
79 * //EXAMPLE: Code fragment
80 * public class Shipping {
81 * @XmlIDREF public Customer getCustomer();
82 * public void setCustomer(Customer customer);
83 * ....
84 * }
85 *
86 * <!-- Example: XML Schema fragment -->
87 * <xs:complexType name="Shipping">
88 * <xs:complexContent>
89 * <xs:sequence>
90 * <xs:element name="customer" type="xs:IDREF"/>
91 * ....
92 * </xs:sequence>
93 * </xs:complexContent>
94 * </xs:complexType>
95 *
96 * </pre>
97 *
98 *
99 * <p><b>Example 2: </b> The following is a complete example of
100 * containment versus reference.
101 *
102 * <pre>
103 * // By default, Customer maps to complex type <tt>xs:Customer</tt>
104 * public class Customer {
105 *
106 * // map JavaBean property type to <tt>xs:ID</tt>
107 * @XmlID public String getCustomerID();
108 * public void setCustomerID(String id);
109 *
110 * // .... other properties not shown
111 * }
112 *
113 *
114 * // By default, Invoice maps to a complex type <tt>xs:Invoice</tt>
126 *
127 * // map by reference
128 * @XmlIDREF public Customer getCustomer();
129 * public void setCustomer(Customer customer);
130 * }
131 *
132 * // at least one class must reference Customer by containment;
133 * // Customer instances won't be marshalled.
134 * @XmlElement(name="CustomerData")
135 * public class CustomerData {
136 * // map reference to Customer by containment by default.
137 * public Customer getCustomer();
138 *
139 * // maps reference to Shipping by containment by default.
140 * public Shipping getShipping();
141 *
142 * // maps reference to Invoice by containment by default.
143 * public Invoice getInvoice();
144 * }
145 *
146 * <!-- XML Schema mapping for above code frament -->
147 *
148 * <xs:complexType name="Invoice">
149 * <xs:complexContent>
150 * <xs:sequence>
151 * <xs:element name="customer" type="xs:IDREF"/>
152 * ....
153 * </xs:sequence>
154 * </xs:complexContent>
155 * </xs:complexType>
156 *
157 * <xs:complexType name="Shipping">
158 * <xs:complexContent>
159 * <xs:sequence>
160 * <xs:element name="customer" type="xs:IDREF"/>
161 * ....
162 * </xs:sequence>
163 * </xs:complexContent>
164 * </xs:complexType>
165 *
166 * <xs:complexType name="Customer">
167 * <xs:complexContent>
168 * <xs:sequence>
169 * ....
170 * </xs:sequence>
171 * <xs:attribute name="CustomerID" type="xs:ID"/>
172 * </xs:complexContent>
173 * </xs:complexType>
174 *
175 * <xs:complexType name="CustomerData">
176 * <xs:complexContent>
177 * <xs:sequence>
178 * <xs:element name="customer" type="xs:Customer"/>
179 * <xs:element name="shipping" type="xs:Shipping"/>
180 * <xs:element name="invoice" type="xs:Invoice"/>
181 * </xs:sequence>
182 * </xs:complexContent>
183 * </xs:complexType>
184 *
185 * <xs:element name"customerData" type="xs:CustomerData"/>
186 *
187 * <!-- Instance document conforming to the above XML Schema -->
188 * <customerData>
189 * <customer customerID="Alice">
190 * ....
191 * </customer>
192 *
193 * <shipping customer="Alice">
194 * ....
195 * </shipping>
196 *
197 * <invoice customer="Alice">
198 * ....
199 * </invoice>
200 * </customerData>
201 *
202 * </pre>
203 *
204 * <p><b>Example 3: </b> Mapping List to repeating element of type IDREF
205 * <pre>
206 * // Code fragment
207 * public class Shipping {
208 * @XmlIDREF
209 * @XmlElement(name="Alice")
210 * public List customers;
211 * }
212 *
213 * <!-- XML schema fragment -->
214 * <xs:complexType name="Shipping">
215 * <xs:sequence>
216 * <xs:choice minOccurs="0" maxOccurs="unbounded">
217 * <xs:element name="Alice" type="xs:IDREF"/>
218 * </xs:choice>
219 * </xs:sequence>
220 * </xs:complexType>
221 * </pre>
222 *
223 * <p><b>Example 4: </b> Mapping a List to a list of elements of type IDREF.
224 * <pre>
225 * //Code fragment
226 * public class Shipping {
227 * @XmlIDREF
228 * @XmlElements(
229 * @XmlElement(name="Alice", type="Customer.class")
230 * @XmlElement(name="John", type="InternationalCustomer.class")
231 * public List customers;
232 * }
233 *
234 * <!-- XML Schema fragment -->
235 * <xs:complexType name="Shipping">
236 * <xs:sequence>
237 * <xs:choice minOccurs="0" maxOccurs="unbounded">
238 * <xs:element name="Alice" type="xs:IDREF"/>
239 * <xs:element name="John" type="xs:IDREF"/>
240 * </xs:choice>
241 * </xs:sequence>
242 * </xs:complexType>
243 * </pre>
244 * @author Sekhar Vajjhala, Sun Microsystems, Inc.
245 * @see XmlID
246 * @since 1.6, JAXB 2.0
247 */
248
249 @Retention(RUNTIME) @Target({FIELD, METHOD})
250 public @interface XmlIDREF {}
|
1 /*
2 * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
66 * property (for non collection type) is java.lang.Object, then
67 * the instance must contain a property/field annotated with
68 * <tt>@XmlID</tt> attribute.
69 * </li>
70 * <li> This annotation can be used with the following annotations:
71 * {@link XmlElement}, {@link XmlAttribute}, {@link XmlList},
72 * and {@link XmlElements}.</li>
73 *
74 * </ul>
75 * <p><b>Example:</b> Map a JavaBean property to <tt>xs:IDREF</tt>
76 * (i.e. by reference rather than by containment)</p>
77 * <pre>
78 *
79 * //EXAMPLE: Code fragment
80 * public class Shipping {
81 * @XmlIDREF public Customer getCustomer();
82 * public void setCustomer(Customer customer);
83 * ....
84 * }
85 *
86 * <!-- Example: XML Schema fragment -->
87 * <xs:complexType name="Shipping">
88 * <xs:complexContent>
89 * <xs:sequence>
90 * <xs:element name="customer" type="xs:IDREF"/>
91 * ....
92 * </xs:sequence>
93 * </xs:complexContent>
94 * </xs:complexType>
95 *
96 * </pre>
97 *
98 *
99 * <p><b>Example 2: </b> The following is a complete example of
100 * containment versus reference.
101 *
102 * <pre>
103 * // By default, Customer maps to complex type <tt>xs:Customer</tt>
104 * public class Customer {
105 *
106 * // map JavaBean property type to <tt>xs:ID</tt>
107 * @XmlID public String getCustomerID();
108 * public void setCustomerID(String id);
109 *
110 * // .... other properties not shown
111 * }
112 *
113 *
114 * // By default, Invoice maps to a complex type <tt>xs:Invoice</tt>
126 *
127 * // map by reference
128 * @XmlIDREF public Customer getCustomer();
129 * public void setCustomer(Customer customer);
130 * }
131 *
132 * // at least one class must reference Customer by containment;
133 * // Customer instances won't be marshalled.
134 * @XmlElement(name="CustomerData")
135 * public class CustomerData {
136 * // map reference to Customer by containment by default.
137 * public Customer getCustomer();
138 *
139 * // maps reference to Shipping by containment by default.
140 * public Shipping getShipping();
141 *
142 * // maps reference to Invoice by containment by default.
143 * public Invoice getInvoice();
144 * }
145 *
146 * <!-- XML Schema mapping for above code frament -->
147 *
148 * <xs:complexType name="Invoice">
149 * <xs:complexContent>
150 * <xs:sequence>
151 * <xs:element name="customer" type="xs:IDREF"/>
152 * ....
153 * </xs:sequence>
154 * </xs:complexContent>
155 * </xs:complexType>
156 *
157 * <xs:complexType name="Shipping">
158 * <xs:complexContent>
159 * <xs:sequence>
160 * <xs:element name="customer" type="xs:IDREF"/>
161 * ....
162 * </xs:sequence>
163 * </xs:complexContent>
164 * </xs:complexType>
165 *
166 * <xs:complexType name="Customer">
167 * <xs:complexContent>
168 * <xs:sequence>
169 * ....
170 * </xs:sequence>
171 * <xs:attribute name="CustomerID" type="xs:ID"/>
172 * </xs:complexContent>
173 * </xs:complexType>
174 *
175 * <xs:complexType name="CustomerData">
176 * <xs:complexContent>
177 * <xs:sequence>
178 * <xs:element name="customer" type="xs:Customer"/>
179 * <xs:element name="shipping" type="xs:Shipping"/>
180 * <xs:element name="invoice" type="xs:Invoice"/>
181 * </xs:sequence>
182 * </xs:complexContent>
183 * </xs:complexType>
184 *
185 * <xs:element name"customerData" type="xs:CustomerData"/>
186 *
187 * <!-- Instance document conforming to the above XML Schema -->
188 * <customerData>
189 * <customer customerID="Alice">
190 * ....
191 * </customer>
192 *
193 * <shipping customer="Alice">
194 * ....
195 * </shipping>
196 *
197 * <invoice customer="Alice">
198 * ....
199 * </invoice>
200 * </customerData>
201 *
202 * </pre>
203 *
204 * <p><b>Example 3: </b> Mapping List to repeating element of type IDREF
205 * <pre>
206 * // Code fragment
207 * public class Shipping {
208 * @XmlIDREF
209 * @XmlElement(name="Alice")
210 * public List customers;
211 * }
212 *
213 * <!-- XML schema fragment -->
214 * <xs:complexType name="Shipping">
215 * <xs:sequence>
216 * <xs:choice minOccurs="0" maxOccurs="unbounded">
217 * <xs:element name="Alice" type="xs:IDREF"/>
218 * </xs:choice>
219 * </xs:sequence>
220 * </xs:complexType>
221 * </pre>
222 *
223 * <p><b>Example 4: </b> Mapping a List to a list of elements of type IDREF.
224 * <pre>
225 * //Code fragment
226 * public class Shipping {
227 * @XmlIDREF
228 * @XmlElements(
229 * @XmlElement(name="Alice", type="Customer.class")
230 * @XmlElement(name="John", type="InternationalCustomer.class")
231 * public List customers;
232 * }
233 *
234 * <!-- XML Schema fragment -->
235 * <xs:complexType name="Shipping">
236 * <xs:sequence>
237 * <xs:choice minOccurs="0" maxOccurs="unbounded">
238 * <xs:element name="Alice" type="xs:IDREF"/>
239 * <xs:element name="John" type="xs:IDREF"/>
240 * </xs:choice>
241 * </xs:sequence>
242 * </xs:complexType>
243 * </pre>
244 * @author Sekhar Vajjhala, Sun Microsystems, Inc.
245 * @see XmlID
246 * @since 1.6, JAXB 2.0
247 */
248
249 @Retention(RUNTIME) @Target({FIELD, METHOD})
250 public @interface XmlIDREF {}
|