KickJava   Java API By Example, From Geeks To Geeks.

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


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

5 package javax.xml.bind.annotation;
6
7 import java.lang.annotation.Retention JavaDoc;
8 import java.lang.annotation.Target JavaDoc;
9
10 import static java.lang.annotation.ElementType.FIELD JavaDoc;
11 import static java.lang.annotation.ElementType.METHOD JavaDoc;
12 import static java.lang.annotation.ElementType.PACKAGE JavaDoc;
13 import static java.lang.annotation.RetentionPolicy.RUNTIME JavaDoc;
14
15 /**
16  * Maps a Java type to a simple schema built-in type.
17  *
18  * <p> <b>Usage</b> </p>
19  * <p>
20  * <tt>@XmlSchemaType</tt> annotation can be used with the following program
21  * elements:
22  * <ul>
23  * <li> a JavaBean property </li>
24  * <li> field </li>
25  * <li> package</li>
26  * </ul>
27  *
28  * <p> <tt>@XmlSchemaType</tt> annotation defined for Java type
29  * applies to all references to the Java type from a property/field.
30  * A <tt>@XmlSchemaType</tt> annotation specified on the
31  * property/field overrides the <tt>@XmlSchemaType</tt> annotation
32  * specified at the package level.
33  *
34  * <p> This annotation can be used with the following annotations:
35  * {@link XmlElement}, {@link XmlAttribute}.
36  * <p>
37  * <b>Example 1: </b> Customize mapping of XMLGregorianCalendar on the
38  * field.
39  *
40  * <pre>
41  * //Example: Code fragment
42  * public class USPrice {
43  * &#64;XmlElement
44  * &#64;XmlSchemaType(name="date")
45  * public XMLGregorianCalendar date;
46  * }
47  *
48  * &lt;!-- Example: Local XML Schema element -->
49  * &lt;xs:complexType name="USPrice"/>
50  * &lt;xs:sequence>
51  * &lt;xs:element name="date" type="xs:date"/>
52  * &lt;/sequence>
53  * &lt;/xs:complexType>
54  * </pre>
55  *
56  * <p> <b> Example 2: </b> Customize mapping of XMLGregorianCalendar at package
57  * level </p>
58  * <pre>
59  * package foo;
60  * &#64;javax.xml.bind.annotation.XmlSchemaType(
61  * name="date", type=javax.xml.datatype.XMLGregorianCalendar.class)
62  * }
63  * </pre>
64  *
65  * @since JAXB2.0
66  */

67
68 @Retention JavaDoc(RUNTIME) @Target JavaDoc({FIELD,METHOD,PACKAGE})
69 public @interface XmlSchemaType {
70     String JavaDoc name();
71     String JavaDoc namespace() default "http://www.w3.org/2001/XMLSchema";
72     /**
73      * If this annotation is used at the package level, then value of
74      * the type() must be specified.
75      */

76
77     Class JavaDoc type() default DEFAULT.class;
78
79     /**
80      * Used in {@link XmlSchemaType#type()} to
81      * signal that the type be inferred from the signature
82      * of the property.
83      */

84
85     static final class DEFAULT {}
86
87 }
88
89
90
91
Popular Tags