01: /*
02: * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
03: * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
04: */
05: package javax.xml.bind.annotation;
06:
07: import java.lang.annotation.Retention;
08: import java.lang.annotation.Target;
09:
10: import static java.lang.annotation.ElementType.FIELD;
11: import static java.lang.annotation.ElementType.METHOD;
12: import static java.lang.annotation.ElementType.PACKAGE;
13: import static java.lang.annotation.RetentionPolicy.RUNTIME;
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: * @XmlElement
44: * @XmlSchemaType(name="date")
45: * public XMLGregorianCalendar date;
46: * }
47: *
48: * <!-- Example: Local XML Schema element -->
49: * <xs:complexType name="USPrice"/>
50: * <xs:sequence>
51: * <xs:element name="date" type="xs:date"/>
52: * </sequence>
53: * </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: * @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(RUNTIME)
69: @Target({FIELD,METHOD,PACKAGE})
70: public @interface XmlSchemaType {
71: String name();
72:
73: String namespace() default "http://www.w3.org/2001/XMLSchema";
74:
75: /**
76: * If this annotation is used at the package level, then value of
77: * the type() must be specified.
78: */
79:
80: Class type() default DEFAULT.class;
81:
82: /**
83: * Used in {@link XmlSchemaType#type()} to
84: * signal that the type be inferred from the signature
85: * of the property.
86: */
87:
88: static final class DEFAULT {
89: }
90:
91: }
|