KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > xml > bind > annotation > XmlValue


1 /*
2  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
3  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
4  */

5
6 package javax.xml.bind.annotation;
7
8 import java.lang.annotation.Target JavaDoc;
9 import java.lang.annotation.Retention JavaDoc;
10 import static java.lang.annotation.ElementType JavaDoc.*;
11 import static java.lang.annotation.RetentionPolicy JavaDoc.*;
12
13 /**
14  * <p>
15  * Enables mapping a class to a XML Schema complex type with a
16  * simpleContent or a XML Schema simple type.
17  * </p>
18  *
19  * <p>
20  * <b> Usage: </b>
21  * <p>
22  * The <tt>@XmlValue</tt> annotation can be used with the following program
23  * elements:
24  * <ul>
25  * <li> a JavaBean property.</li>
26  * <li> non static, non transient field.</li>
27  * </ul>
28  *
29  * <p>See "Package Specification" in javax.xml.bind.package javadoc for
30  * additional common information.</p>
31  *
32  * The usage is subject to the following usage constraints:
33  * <ul>
34  * <li>At most one field or property can be annotated with the
35  * <tt>@XmlValue</tt> annotation. </li>
36  *
37  * <li><tt>@XmlValue</tt> can be used with the following
38  * annotations: {@link XmlList}. However this is redundant since
39  * {@link XmlList} maps a type to a simple schema type that derives by
40  * list just as {@link XmlValue} would. </li>
41  *
42  * <li>If the type of the field or property is a collection type,
43  * then the collection item type must map to a simple schema
44  * type. </li>
45  *
46  * <li>If the type of the field or property is not a collection
47  * type, then the type must map to a XML Schema simple type. </li>
48  *
49  * </ul>
50  * </p>
51  * <p>
52  * If the annotated JavaBean property is the sole class member being
53  * mapped to XML Schema construct, then the class is mapped to a
54  * simple type.
55  *
56  * If there are additional JavaBean properties (other than the
57  * JavaBean property annotated with <tt>@XmlValue</tt> annotation)
58  * that are mapped to XML attributes, then the class is mapped to a
59  * complex type with simpleContent.
60  * </p>
61  *
62  * <p> <b> Example 1: </b> Map a class to XML Schema simpleType</p>
63  *
64  * <pre>
65  *
66  * // Example 1: Code fragment
67  * public class USPrice {
68  * &#64;XmlValue
69  * public java.math.BigDecimal price;
70  * }
71  *
72  * &lt;!-- Example 1: XML Schema fragment -->
73  * &lt;xs:simpleType name="USPrice">
74  * &lt;xs:restriction base="xs:decimal"/>
75  * &lt;/xs:simpleType>
76  *
77  * </pre>
78  *
79  * <p><b> Example 2: </b> Map a class to XML Schema complexType with
80  * with simpleContent.</p>
81  *
82  * <pre>
83  *
84  * // Example 2: Code fragment
85  * public class InternationalPrice {
86  * &#64;XmlValue
87  * public java.math.BigDecimal price;
88  *
89  * &#64;XmlAttribute
90  * public String currency;
91  * }
92  *
93  * &lt;!-- Example 2: XML Schema fragment -->
94  * &lt;xs:complexType name="InternationalPrice">
95  * &lt;xs:simpleContent>
96  * &lt;xs:extension base="xs:decimal">
97  * &lt;xs:attribute name="currency" type="xs:string"/>
98  * &lt;/xs:extension>
99  * &lt;/xs:simpleContent>
100  * &lt;/xs:complexType>
101  *
102  * </pre>
103  * </p>
104  *
105  * @author Sekhar Vajjhala, Sun Microsystems, Inc.
106  * @see XmlType
107  * @since JAXB2.0
108  * @version $Revision: 1.5 $
109  */

110
111 @Retention JavaDoc(RUNTIME) @Target JavaDoc({FIELD, METHOD})
112 public @interface XmlValue {}
113
Popular Tags