author | avstepan |
Thu, 24 Sep 2015 18:26:42 +0300 | |
changeset 32795 | 5a5710ee05a0 |
parent 29839 | 6d5d546e953b |
child 47210 | 1edad689f56c |
permissions | -rw-r--r-- |
12009 | 1 |
/* |
28887
88470f768658
8071585: Update JAX-WS RI integration to latest version (2.2.11-b150127.1410)
aefimov
parents:
25871
diff
changeset
|
2 |
* Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved. |
12009 | 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 |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
package javax.xml.bind.annotation; |
|
27 |
||
28 |
import static java.lang.annotation.ElementType.TYPE; |
|
29 |
import java.lang.annotation.Retention; |
|
30 |
import static java.lang.annotation.RetentionPolicy.RUNTIME; |
|
31 |
import java.lang.annotation.Target; |
|
32 |
||
33 |
/** |
|
34 |
* <p> |
|
35 |
* Maps a class or an enum type to a XML Schema type. |
|
36 |
* |
|
37 |
* <p><b>Usage</b></p> |
|
32795
5a5710ee05a0
8133651: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
29839
diff
changeset
|
38 |
* <p> The {@code @XmlType} annnotation can be used with the following program |
12009 | 39 |
* elements: |
40 |
* <ul> |
|
41 |
* <li> a top level class </li> |
|
42 |
* <li> an enum type </li> |
|
43 |
* </ul> |
|
44 |
* |
|
45 |
* <p>See "Package Specification" in javax.xml.bind.package javadoc for |
|
46 |
* additional common information.</p> |
|
47 |
* |
|
48 |
* <h3> Mapping a Class </h3> |
|
49 |
* <p> |
|
50 |
* A class maps to a XML Schema type. A class is a data container for |
|
51 |
* values represented by properties and fields. A schema type is a |
|
52 |
* data container for values represented by schema components within a |
|
53 |
* schema type's content model (e.g. model groups, attributes etc). |
|
54 |
* <p> To be mapped, a class must either have a public no-arg |
|
55 |
* constructor or a static no-arg factory method. The static factory |
|
32795
5a5710ee05a0
8133651: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
29839
diff
changeset
|
56 |
* method can be specified in {@code factoryMethod()} and |
5a5710ee05a0
8133651: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
29839
diff
changeset
|
57 |
* {@code factoryClass()} annotation elements. The static factory |
12009 | 58 |
* method or the no-arg constructor is used during unmarshalling to |
59 |
* create an instance of this class. If both are present, the static |
|
60 |
* factory method overrides the no-arg constructor. |
|
61 |
* <p> |
|
62 |
* A class maps to either a XML Schema complex type or a XML Schema simple |
|
63 |
* type. The XML Schema type is derived based on the |
|
64 |
* mapping of JavaBean properties and fields contained within the |
|
65 |
* class. The schema type to which the class is mapped can either be |
|
66 |
* named or anonymous. A class can be mapped to an anonymous schema |
|
32795
5a5710ee05a0
8133651: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
29839
diff
changeset
|
67 |
* type by annotating the class with {@code @XmlType(name="")}. |
12009 | 68 |
* <p> |
69 |
* Either a global element, local element or a local attribute can be |
|
70 |
* associated with an anonymous type as follows: |
|
71 |
* <ul> |
|
72 |
* <li><b>global element: </b> A global element of an anonymous |
|
73 |
* type can be derived by annotating the class with @{@link |
|
74 |
* XmlRootElement}. See Example 3 below. </li> |
|
75 |
* |
|
76 |
* <li><b>local element: </b> A JavaBean property that references |
|
77 |
* a class annotated with @XmlType(name="") and is mapped to the |
|
78 |
* element associated with the anonymous type. See Example 4 |
|
79 |
* below.</li> |
|
80 |
* |
|
81 |
* <li><b>attribute: </b> A JavaBean property that references |
|
82 |
* a class annotated with @XmlType(name="") and is mapped to the |
|
83 |
* attribute associated with the anonymous type. See Example 5 below. </li> |
|
84 |
* </ul> |
|
85 |
* <b> Mapping to XML Schema Complex Type </b> |
|
86 |
* <ul> |
|
32795
5a5710ee05a0
8133651: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
29839
diff
changeset
|
87 |
* <li>If class is annotated with {@code @XmlType(name="") }, it |
12009 | 88 |
* is mapped to an anonymous type otherwise, the class name maps |
32795
5a5710ee05a0
8133651: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
29839
diff
changeset
|
89 |
* to a complex type name. The {@code XmlName()} annotation element |
12009 | 90 |
* can be used to customize the name.</li> |
91 |
* |
|
92 |
* <li> Properties and fields that are mapped to elements are mapped to a |
|
93 |
* content model within a complex type. The annotation element |
|
32795
5a5710ee05a0
8133651: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
29839
diff
changeset
|
94 |
* {@code propOrder()} can be used to customize the content model to be |
5a5710ee05a0
8133651: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
29839
diff
changeset
|
95 |
* {@code xs:all} or {@code xs:sequence}. It is used for specifying |
5a5710ee05a0
8133651: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
29839
diff
changeset
|
96 |
* the order of XML elements in {@code xs:sequence}. </li> |
12009 | 97 |
* |
98 |
* <li> Properties and fields can be mapped to attributes within the |
|
99 |
* complex type. </li> |
|
100 |
* |
|
101 |
* <li> The targetnamespace of the XML Schema type can be customized |
|
32795
5a5710ee05a0
8133651: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
29839
diff
changeset
|
102 |
* using the annotation element {@code namespace()}. </li> |
12009 | 103 |
* </ul> |
104 |
* |
|
105 |
* <p> |
|
106 |
* <b> Mapping class to XML Schema simple type </b> |
|
107 |
* <p> |
|
108 |
* A class can be mapped to a XML Schema simple type using the |
|
32795
5a5710ee05a0
8133651: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
29839
diff
changeset
|
109 |
* {@code @XmlValue} annotation. For additional details and examples, |
12009 | 110 |
* see @{@link XmlValue} annotation type. |
111 |
* <p> |
|
112 |
* The following table shows the mapping of the class to a XML Schema |
|
113 |
* complex type or simple type. The notational symbols used in the table are: |
|
114 |
* <ul> |
|
29839
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
115 |
* <li> {@literal ->} : represents a mapping </li> |
12009 | 116 |
* <li> [x]+ : one or more occurances of x </li> |
32795
5a5710ee05a0
8133651: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
29839
diff
changeset
|
117 |
* <li> [ {@code @XmlValue} property ]: JavaBean property annotated with |
5a5710ee05a0
8133651: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
29839
diff
changeset
|
118 |
* {@code @XmlValue}</li> |
12009 | 119 |
* <li> X : don't care |
120 |
* </ul> |
|
121 |
* <blockquote> |
|
28887
88470f768658
8071585: Update JAX-WS RI integration to latest version (2.2.11-b150127.1410)
aefimov
parents:
25871
diff
changeset
|
122 |
* <table summary="" border="1" cellpadding="4" cellspacing="3"> |
12009 | 123 |
* <tbody> |
124 |
* <tr> |
|
125 |
* <td><b>Target</b></td> |
|
126 |
* <td><b>propOrder</b></td> |
|
127 |
* <td><b>ClassBody</b></td> |
|
128 |
* <td><b>ComplexType</b></td> |
|
129 |
* <td><b>SimpleType</b></td> |
|
130 |
* </tr> |
|
131 |
* |
|
132 |
* <tr valign="top"> |
|
133 |
* <td>Class</td> |
|
134 |
* <td>{}</td> |
|
29839
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
135 |
* <td>[property]+ {@literal ->} elements</td> |
12009 | 136 |
* <td>complexcontent<br>xs:all</td> |
137 |
* <td> </td> |
|
138 |
* </tr> |
|
139 |
* |
|
140 |
* <tr valign="top"> |
|
141 |
* <td>Class</td> |
|
142 |
* <td>non empty</td> |
|
29839
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
143 |
* <td>[property]+ {@literal ->} elements</td> |
12009 | 144 |
* <td>complexcontent<br>xs:sequence</td> |
145 |
* <td> </td> |
|
146 |
* </tr> |
|
147 |
* |
|
148 |
* <tr valign="top"> |
|
149 |
* <td>Class</td> |
|
150 |
* <td>X</td> |
|
29839
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
151 |
* <td>no property {@literal ->} element</td> |
12009 | 152 |
* <td>complexcontent<br>empty sequence</td> |
153 |
* <td> </td> |
|
154 |
* </tr> |
|
155 |
* |
|
156 |
* <tr valign="top"> |
|
157 |
* <td>Class</td> |
|
158 |
* <td>X</td> |
|
32795
5a5710ee05a0
8133651: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
29839
diff
changeset
|
159 |
* <td>1 [{@code @XmlValue} property] {@literal &&} <br> [property]+ {@literal ->} attributes</td> |
12009 | 160 |
* <td>simplecontent</td> |
161 |
* <td> </td> |
|
162 |
* </tr> |
|
163 |
* |
|
164 |
* <tr valign="top"> |
|
165 |
* <td>Class</td> |
|
166 |
* <td>X</td> |
|
32795
5a5710ee05a0
8133651: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
29839
diff
changeset
|
167 |
* <td>1 [{@code @XmlValue} property] {@literal &&} <br> no properties {@literal ->} attribute</td> |
12009 | 168 |
* <td> </td> |
169 |
* <td>simpletype</td> |
|
170 |
* </tr> |
|
171 |
* </tbody> |
|
172 |
* </table> |
|
173 |
* </blockquote> |
|
174 |
* |
|
175 |
* <h3> Mapping an enum type </h3> |
|
176 |
* |
|
177 |
* An enum type maps to a XML schema simple type with enumeration |
|
178 |
* facets. The following annotation elements are ignored since they |
|
32795
5a5710ee05a0
8133651: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
29839
diff
changeset
|
179 |
* are not meaningful: {@code propOrder()} , {@code factoryMethod()} , |
5a5710ee05a0
8133651: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
29839
diff
changeset
|
180 |
* {@code factoryClass()} . |
12009 | 181 |
* |
182 |
* <h3> Usage with other annotations </h3> |
|
183 |
* <p> This annotation can be used with the following annotations: |
|
184 |
* {@link XmlRootElement}, {@link XmlAccessorOrder}, {@link XmlAccessorType}, |
|
185 |
* {@link XmlEnum}. However, {@link |
|
186 |
* XmlAccessorOrder} and {@link XmlAccessorType} are ignored when this |
|
187 |
* annotation is used on an enum type. |
|
188 |
* |
|
189 |
* <p> <b> Example 1: </b> Map a class to a complex type with |
|
190 |
* xs:sequence with a customized ordering of JavaBean properties. |
|
191 |
* </p> |
|
192 |
* |
|
193 |
* <pre> |
|
194 |
* @XmlType(propOrder={"street", "city" , "state", "zip", "name" }) |
|
195 |
* public class USAddress { |
|
196 |
* String getName() {..}; |
|
197 |
* void setName(String) {..}; |
|
198 |
* |
|
199 |
* String getStreet() {..}; |
|
200 |
* void setStreet(String) {..}; |
|
201 |
* |
|
202 |
* String getCity() {..}; |
|
203 |
* void setCity(String) {..}; |
|
204 |
* |
|
205 |
* String getState() {..}; |
|
206 |
* void setState(String) {..}; |
|
207 |
* |
|
208 |
* java.math.BigDecimal getZip() {..}; |
|
209 |
* void setZip(java.math.BigDecimal) {..}; |
|
210 |
* } |
|
29839
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
211 |
* {@code |
12009 | 212 |
* |
29839
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
213 |
* <!-- XML Schema mapping for USAddress --> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
214 |
* <xs:complexType name="USAddress"> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
215 |
* <xs:sequence> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
216 |
* <xs:element name="street" type="xs:string"/> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
217 |
* <xs:element name="city" type="xs:string"/> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
218 |
* <xs:element name="state" type="xs:string"/> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
219 |
* <xs:element name="zip" type="xs:decimal"/> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
220 |
* <xs:element name="name" type="xs:string"/> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
221 |
* </xs:all> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
222 |
* </xs:complexType> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
223 |
* }</pre> |
12009 | 224 |
* <p> <b> Example 2: </b> Map a class to a complex type with |
225 |
* xs:all </p> |
|
226 |
* <pre> |
|
227 |
* @XmlType(propOrder={}) |
|
228 |
* public class USAddress { ...} |
|
29839
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
229 |
* {@code |
12009 | 230 |
* |
29839
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
231 |
* <!-- XML Schema mapping for USAddress --> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
232 |
* <xs:complexType name="USAddress"> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
233 |
* <xs:all> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
234 |
* <xs:element name="name" type="xs:string"/> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
235 |
* <xs:element name="street" type="xs:string"/> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
236 |
* <xs:element name="city" type="xs:string"/> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
237 |
* <xs:element name="state" type="xs:string"/> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
238 |
* <xs:element name="zip" type="xs:decimal"/> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
239 |
* </xs:sequence> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
240 |
* </xs:complexType> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
241 |
*}</pre> |
12009 | 242 |
* <p> <b> Example 3: </b> Map a class to a global element with an |
243 |
* anonymous type. |
|
244 |
* </p> |
|
245 |
* <pre> |
|
246 |
* @XmlRootElement |
|
247 |
* @XmlType(name="") |
|
248 |
* public class USAddress { ...} |
|
29839
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
249 |
* {@code |
12009 | 250 |
* |
29839
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
251 |
* <!-- XML Schema mapping for USAddress --> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
252 |
* <xs:element name="USAddress"> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
253 |
* <xs:complexType> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
254 |
* <xs:sequence> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
255 |
* <xs:element name="name" type="xs:string"/> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
256 |
* <xs:element name="street" type="xs:string"/> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
257 |
* <xs:element name="city" type="xs:string"/> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
258 |
* <xs:element name="state" type="xs:string"/> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
259 |
* <xs:element name="zip" type="xs:decimal"/> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
260 |
* </xs:sequence> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
261 |
* </xs:complexType> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
262 |
* </xs:element> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
263 |
* }</pre> |
12009 | 264 |
* |
265 |
* <p> <b> Example 4: </b> Map a property to a local element with |
|
28887
88470f768658
8071585: Update JAX-WS RI integration to latest version (2.2.11-b150127.1410)
aefimov
parents:
25871
diff
changeset
|
266 |
* anonymous type. |
12009 | 267 |
* <pre> |
268 |
* //Example: Code fragment |
|
269 |
* public class Invoice { |
|
270 |
* USAddress addr; |
|
271 |
* ... |
|
272 |
* } |
|
273 |
* |
|
274 |
* @XmlType(name="") |
|
275 |
* public class USAddress { ... } |
|
276 |
* } |
|
29839
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
277 |
* {@code |
12009 | 278 |
* |
29839
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
279 |
* <!-- XML Schema mapping for USAddress --> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
280 |
* <xs:complexType name="Invoice"> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
281 |
* <xs:sequence> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
282 |
* <xs:element name="addr"> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
283 |
* <xs:complexType> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
284 |
* <xs:element name="name", type="xs:string"/> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
285 |
* <xs:element name="city", type="xs:string"/> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
286 |
* <xs:element name="city" type="xs:string"/> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
287 |
* <xs:element name="state" type="xs:string"/> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
288 |
* <xs:element name="zip" type="xs:decimal"/> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
289 |
* </xs:complexType> |
12009 | 290 |
* ... |
29839
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
291 |
* </xs:sequence> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
292 |
* </xs:complexType> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
293 |
* }</pre> |
12009 | 294 |
* |
295 |
* <p> <b> Example 5: </b> Map a property to an attribute with |
|
296 |
* anonymous type. |
|
297 |
* |
|
298 |
* <pre> |
|
299 |
* |
|
300 |
* //Example: Code fragment |
|
301 |
* public class Item { |
|
302 |
* public String name; |
|
303 |
* @XmlAttribute |
|
304 |
* public USPrice price; |
|
305 |
* } |
|
306 |
* |
|
307 |
* // map class to anonymous simple type. |
|
308 |
* @XmlType(name="") |
|
309 |
* public class USPrice { |
|
310 |
* @XmlValue |
|
311 |
* public java.math.BigDecimal price; |
|
312 |
* } |
|
29839
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
313 |
* {@code |
12009 | 314 |
* |
29839
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
315 |
* <!-- Example: XML Schema fragment --> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
316 |
* <xs:complexType name="Item"> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
317 |
* <xs:sequence> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
318 |
* <xs:element name="name" type="xs:string"/> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
319 |
* <xs:attribute name="price"> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
320 |
* <xs:simpleType> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
321 |
* <xs:restriction base="xs:decimal"/> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
322 |
* </xs:simpleType> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
323 |
* </xs:attribute> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
324 |
* </xs:sequence> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
325 |
* </xs:complexType> |
6d5d546e953b
8076549: Update JAX-WS RI integration to latest version (2.2.11-b150402.1412)
aefimov
parents:
28887
diff
changeset
|
326 |
* }</pre> |
12009 | 327 |
* |
328 |
* <p> <b> Example 6: </b> Define a factoryClass and factoryMethod |
|
329 |
* |
|
330 |
* <pre> |
|
331 |
* @XmlType(name="USAddressType", factoryClass=USAddressFactory.class, |
|
332 |
* factoryMethod="getUSAddress") |
|
333 |
* public class USAddress { |
|
334 |
* |
|
335 |
* private String city; |
|
336 |
* private String name; |
|
337 |
* private String state; |
|
338 |
* private String street; |
|
339 |
* private int zip; |
|
340 |
* |
|
341 |
* public USAddress(String name, String street, String city, |
|
342 |
* String state, int zip) { |
|
343 |
* this.name = name; |
|
344 |
* this.street = street; |
|
345 |
* this.city = city; |
|
346 |
* this.state = state; |
|
347 |
* this.zip = zip; |
|
348 |
* } |
|
349 |
* } |
|
350 |
* |
|
351 |
* public class USAddressFactory { |
|
352 |
* public static USAddress getUSAddress(){ |
|
353 |
* return new USAddress("Mark Baker", "23 Elm St", |
|
354 |
* "Dayton", "OH", 90952); |
|
355 |
* } |
|
356 |
* |
|
357 |
* </pre> |
|
358 |
* |
|
359 |
* <p> <b> Example 7: </b> Define factoryMethod and use the default factoryClass |
|
360 |
* |
|
361 |
* <pre> |
|
362 |
* @XmlType(name="USAddressType", factoryMethod="getNewInstance") |
|
363 |
* public class USAddress { |
|
364 |
* |
|
365 |
* private String city; |
|
366 |
* private String name; |
|
367 |
* private String state; |
|
368 |
* private String street; |
|
369 |
* private int zip; |
|
370 |
* |
|
371 |
* private USAddress() {} |
|
372 |
* |
|
373 |
* public static USAddress getNewInstance(){ |
|
374 |
* return new USAddress(); |
|
375 |
* } |
|
376 |
* } |
|
377 |
* </pre> |
|
378 |
* |
|
379 |
* @author Sekhar Vajjhala, Sun Microsystems, Inc. |
|
380 |
* @see XmlElement |
|
381 |
* @see XmlAttribute |
|
382 |
* @see XmlValue |
|
383 |
* @see XmlSchema |
|
25840 | 384 |
* @since 1.6, JAXB 2.0 |
12009 | 385 |
*/ |
386 |
||
387 |
@Retention(RUNTIME) @Target({TYPE}) |
|
388 |
public @interface XmlType { |
|
389 |
/** |
|
390 |
* Name of the XML Schema type which the class is mapped. |
|
391 |
*/ |
|
392 |
String name() default "##default" ; |
|
393 |
||
394 |
/** |
|
395 |
* Specifies the order for XML Schema elements when class is |
|
396 |
* mapped to a XML Schema complex type. |
|
397 |
* |
|
398 |
* <p> Refer to the table for how the propOrder affects the |
|
399 |
* mapping of class </p> |
|
400 |
* |
|
401 |
* <p> The propOrder is a list of names of JavaBean properties in |
|
402 |
* the class. Each name in the list is the name of a Java |
|
403 |
* identifier of the JavaBean property. The order in which |
|
404 |
* JavaBean properties are listed is the order of XML Schema |
|
405 |
* elements to which the JavaBean properties are mapped. </p> |
|
406 |
* <p> All of the JavaBean properties being mapped to XML Schema elements |
|
407 |
* must be listed. |
|
408 |
* <p> A JavaBean property or field listed in propOrder must not |
|
32795
5a5710ee05a0
8133651: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
29839
diff
changeset
|
409 |
* be transient or annotated with {@code @XmlTransient}. |
12009 | 410 |
* <p> The default ordering of JavaBean properties is determined |
411 |
* by @{@link XmlAccessorOrder}. |
|
412 |
*/ |
|
413 |
String[] propOrder() default {""}; |
|
414 |
||
415 |
/** |
|
416 |
* Name of the target namespace of the XML Schema type. By |
|
417 |
* default, this is the target namespace to which the package |
|
418 |
* containing the class is mapped. |
|
419 |
*/ |
|
420 |
String namespace() default "##default" ; |
|
421 |
||
422 |
/** |
|
423 |
* Class containing a no-arg factory method for creating an |
|
424 |
* instance of this class. The default is this class. |
|
425 |
* |
|
32795
5a5710ee05a0
8133651: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
29839
diff
changeset
|
426 |
* <p>If {@code factoryClass} is DEFAULT.class and |
5a5710ee05a0
8133651: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
29839
diff
changeset
|
427 |
* {@code factoryMethod} is "", then there is no static factory |
12009 | 428 |
* method. |
429 |
* |
|
32795
5a5710ee05a0
8133651: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
29839
diff
changeset
|
430 |
* <p>If {@code factoryClass} is DEFAULT.class and |
5a5710ee05a0
8133651: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
29839
diff
changeset
|
431 |
* {@code factoryMethod} is not "", then |
5a5710ee05a0
8133651: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
29839
diff
changeset
|
432 |
* {@code factoryMethod} is the name of a static factory method |
12009 | 433 |
* in this class. |
434 |
* |
|
32795
5a5710ee05a0
8133651: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
29839
diff
changeset
|
435 |
* <p>If {@code factoryClass} is not DEFAULT.class, then |
5a5710ee05a0
8133651: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
29839
diff
changeset
|
436 |
* {@code factoryMethod} must not be "" and must be the name of |
5a5710ee05a0
8133651: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
29839
diff
changeset
|
437 |
* a static factory method specified in {@code factoryClass}. |
12009 | 438 |
*/ |
439 |
Class factoryClass() default DEFAULT.class; |
|
440 |
||
441 |
/** |
|
442 |
* Used in {@link XmlType#factoryClass()} to |
|
443 |
* signal that either factory mehod is not used or |
|
444 |
* that it's in the class with this {@link XmlType} itself. |
|
445 |
*/ |
|
446 |
static final class DEFAULT {} |
|
447 |
||
448 |
/** |
|
449 |
* Name of a no-arg factory method in the class specified in |
|
32795
5a5710ee05a0
8133651: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
29839
diff
changeset
|
450 |
* {@code factoryClass} factoryClass(). |
12009 | 451 |
* |
452 |
*/ |
|
453 |
String factoryMethod() default ""; |
|
454 |
} |