1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/jaxws_classes/javax/xml/bind/annotation/XmlValue.java Wed Apr 27 01:27:09 2016 +0800 1.3 @@ -0,0 +1,131 @@ 1.4 +/* 1.5 + * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. Oracle designates this 1.11 + * particular file as subject to the "Classpath" exception as provided 1.12 + * by Oracle in the LICENSE file that accompanied this code. 1.13 + * 1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.17 + * version 2 for more details (a copy is included in the LICENSE file that 1.18 + * accompanied this code). 1.19 + * 1.20 + * You should have received a copy of the GNU General Public License version 1.21 + * 2 along with this work; if not, write to the Free Software Foundation, 1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.23 + * 1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.25 + * or visit www.oracle.com if you need additional information or have any 1.26 + * questions. 1.27 + */ 1.28 + 1.29 +package javax.xml.bind.annotation; 1.30 + 1.31 +import java.lang.annotation.Target; 1.32 +import java.lang.annotation.Retention; 1.33 +import static java.lang.annotation.ElementType.*; 1.34 +import static java.lang.annotation.RetentionPolicy.*; 1.35 + 1.36 +/** 1.37 + * <p> 1.38 + * Enables mapping a class to a XML Schema complex type with a 1.39 + * simpleContent or a XML Schema simple type. 1.40 + * </p> 1.41 + * 1.42 + * <p> 1.43 + * <b> Usage: </b> 1.44 + * <p> 1.45 + * The <tt>@XmlValue</tt> annotation can be used with the following program 1.46 + * elements: 1.47 + * <ul> 1.48 + * <li> a JavaBean property.</li> 1.49 + * <li> non static, non transient field.</li> 1.50 + * </ul> 1.51 + * 1.52 + * <p>See "Package Specification" in javax.xml.bind.package javadoc for 1.53 + * additional common information.</p> 1.54 + * 1.55 + * The usage is subject to the following usage constraints: 1.56 + * <ul> 1.57 + * <li>At most one field or property can be annotated with the 1.58 + * <tt>@XmlValue</tt> annotation. </li> 1.59 + * 1.60 + * <li><tt>@XmlValue</tt> can be used with the following 1.61 + * annotations: {@link XmlList}. However this is redundant since 1.62 + * {@link XmlList} maps a type to a simple schema type that derives by 1.63 + * list just as {@link XmlValue} would. </li> 1.64 + * 1.65 + * <li>If the type of the field or property is a collection type, 1.66 + * then the collection item type must map to a simple schema 1.67 + * type. </li> 1.68 + * 1.69 + * <li>If the type of the field or property is not a collection 1.70 + * type, then the type must map to a XML Schema simple type. </li> 1.71 + * 1.72 + * </ul> 1.73 + * </p> 1.74 + * <p> 1.75 + * If the annotated JavaBean property is the sole class member being 1.76 + * mapped to XML Schema construct, then the class is mapped to a 1.77 + * simple type. 1.78 + * 1.79 + * If there are additional JavaBean properties (other than the 1.80 + * JavaBean property annotated with <tt>@XmlValue</tt> annotation) 1.81 + * that are mapped to XML attributes, then the class is mapped to a 1.82 + * complex type with simpleContent. 1.83 + * </p> 1.84 + * 1.85 + * <p> <b> Example 1: </b> Map a class to XML Schema simpleType</p> 1.86 + * 1.87 + * <pre> 1.88 + * 1.89 + * // Example 1: Code fragment 1.90 + * public class USPrice { 1.91 + * @XmlValue 1.92 + * public java.math.BigDecimal price; 1.93 + * } 1.94 + * 1.95 + * <!-- Example 1: XML Schema fragment --> 1.96 + * <xs:simpleType name="USPrice"> 1.97 + * <xs:restriction base="xs:decimal"/> 1.98 + * </xs:simpleType> 1.99 + * 1.100 + * </pre> 1.101 + * 1.102 + * <p><b> Example 2: </b> Map a class to XML Schema complexType with 1.103 + * with simpleContent.</p> 1.104 + * 1.105 + * <pre> 1.106 + * 1.107 + * // Example 2: Code fragment 1.108 + * public class InternationalPrice { 1.109 + * @XmlValue 1.110 + * public java.math.BigDecimal price; 1.111 + * 1.112 + * @XmlAttribute 1.113 + * public String currency; 1.114 + * } 1.115 + * 1.116 + * <!-- Example 2: XML Schema fragment --> 1.117 + * <xs:complexType name="InternationalPrice"> 1.118 + * <xs:simpleContent> 1.119 + * <xs:extension base="xs:decimal"> 1.120 + * <xs:attribute name="currency" type="xs:string"/> 1.121 + * </xs:extension> 1.122 + * </xs:simpleContent> 1.123 + * </xs:complexType> 1.124 + * 1.125 + * </pre> 1.126 + * </p> 1.127 + * 1.128 + * @author Sekhar Vajjhala, Sun Microsystems, Inc. 1.129 + * @see XmlType 1.130 + * @since JAXB2.0 1.131 + */ 1.132 + 1.133 +@Retention(RUNTIME) @Target({FIELD, METHOD}) 1.134 +public @interface XmlValue {}