src/share/jaxws_classes/javax/xml/bind/annotation/XmlSchemaType.java

Thu, 31 Aug 2017 15:18:52 +0800

author
aoqi
date
Thu, 31 Aug 2017 15:18:52 +0800
changeset 637
9c07ef4934dd
parent 397
b99d7e355d4b
parent 0
373ffda63c9a
permissions
-rw-r--r--

merge

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation. Oracle designates this
aoqi@0 8 * particular file as subject to the "Classpath" exception as provided
aoqi@0 9 * by Oracle in the LICENSE file that accompanied this code.
aoqi@0 10 *
aoqi@0 11 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 14 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 15 * accompanied this code).
aoqi@0 16 *
aoqi@0 17 * You should have received a copy of the GNU General Public License version
aoqi@0 18 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 20 *
aoqi@0 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 22 * or visit www.oracle.com if you need additional information or have any
aoqi@0 23 * questions.
aoqi@0 24 */
aoqi@0 25
aoqi@0 26 package javax.xml.bind.annotation;
aoqi@0 27
aoqi@0 28 import java.lang.annotation.Retention;
aoqi@0 29 import java.lang.annotation.Target;
aoqi@0 30
aoqi@0 31 import static java.lang.annotation.ElementType.FIELD;
aoqi@0 32 import static java.lang.annotation.ElementType.METHOD;
aoqi@0 33 import static java.lang.annotation.ElementType.PACKAGE;
aoqi@0 34 import static java.lang.annotation.RetentionPolicy.RUNTIME;
aoqi@0 35
aoqi@0 36 /**
aoqi@0 37 * Maps a Java type to a simple schema built-in type.
aoqi@0 38 *
aoqi@0 39 * <p> <b>Usage</b> </p>
aoqi@0 40 * <p>
aoqi@0 41 * <tt>@XmlSchemaType</tt> annotation can be used with the following program
aoqi@0 42 * elements:
aoqi@0 43 * <ul>
aoqi@0 44 * <li> a JavaBean property </li>
aoqi@0 45 * <li> field </li>
aoqi@0 46 * <li> package</li>
aoqi@0 47 * </ul>
aoqi@0 48 *
aoqi@0 49 * <p> <tt>@XmlSchemaType</tt> annotation defined for Java type
aoqi@0 50 * applies to all references to the Java type from a property/field.
aoqi@0 51 * A <tt>@XmlSchemaType</tt> annotation specified on the
aoqi@0 52 * property/field overrides the <tt>@XmlSchemaType</tt> annotation
aoqi@0 53 * specified at the package level.
aoqi@0 54 *
aoqi@0 55 * <p> This annotation can be used with the following annotations:
aoqi@0 56 * {@link XmlElement}, {@link XmlAttribute}.
aoqi@0 57 * <p>
aoqi@0 58 * <b>Example 1: </b> Customize mapping of XMLGregorianCalendar on the
aoqi@0 59 * field.
aoqi@0 60 *
aoqi@0 61 * <pre>
aoqi@0 62 * //Example: Code fragment
aoqi@0 63 * public class USPrice {
aoqi@0 64 * &#64;XmlElement
aoqi@0 65 * &#64;XmlSchemaType(name="date")
aoqi@0 66 * public XMLGregorianCalendar date;
aoqi@0 67 * }
aoqi@0 68 *
aoqi@0 69 * &lt;!-- Example: Local XML Schema element -->
aoqi@0 70 * &lt;xs:complexType name="USPrice"/>
aoqi@0 71 * &lt;xs:sequence>
aoqi@0 72 * &lt;xs:element name="date" type="xs:date"/>
aoqi@0 73 * &lt;/sequence>
aoqi@0 74 * &lt;/xs:complexType>
aoqi@0 75 * </pre>
aoqi@0 76 *
aoqi@0 77 * <p> <b> Example 2: </b> Customize mapping of XMLGregorianCalendar at package
aoqi@0 78 * level </p>
aoqi@0 79 * <pre>
aoqi@0 80 * package foo;
aoqi@0 81 * &#64;javax.xml.bind.annotation.XmlSchemaType(
aoqi@0 82 * name="date", type=javax.xml.datatype.XMLGregorianCalendar.class)
aoqi@0 83 * }
aoqi@0 84 * </pre>
aoqi@0 85 *
aoqi@0 86 * @since JAXB2.0
aoqi@0 87 */
aoqi@0 88
aoqi@0 89 @Retention(RUNTIME) @Target({FIELD,METHOD,PACKAGE})
aoqi@0 90 public @interface XmlSchemaType {
aoqi@0 91 String name();
aoqi@0 92 String namespace() default "http://www.w3.org/2001/XMLSchema";
aoqi@0 93 /**
aoqi@0 94 * If this annotation is used at the package level, then value of
aoqi@0 95 * the type() must be specified.
aoqi@0 96 */
aoqi@0 97
aoqi@0 98 Class type() default DEFAULT.class;
aoqi@0 99
aoqi@0 100 /**
aoqi@0 101 * Used in {@link XmlSchemaType#type()} to
aoqi@0 102 * signal that the type be inferred from the signature
aoqi@0 103 * of the property.
aoqi@0 104 */
aoqi@0 105
aoqi@0 106 static final class DEFAULT {}
aoqi@0 107
aoqi@0 108 }

mercurial