Tue, 09 Apr 2013 14:51:13 +0100
8010393: Update JAX-WS RI to 2.2.9-b12941
Reviewed-by: alanb, erikj
Contributed-by: miroslav.kos@oracle.com, martin.grebac@oracle.com
ohair@286 | 1 | /* |
ohair@286 | 2 | * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. |
ohair@286 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ohair@286 | 4 | * |
ohair@286 | 5 | * This code is free software; you can redistribute it and/or modify it |
ohair@286 | 6 | * under the terms of the GNU General Public License version 2 only, as |
ohair@286 | 7 | * published by the Free Software Foundation. Oracle designates this |
ohair@286 | 8 | * particular file as subject to the "Classpath" exception as provided |
ohair@286 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
ohair@286 | 10 | * |
ohair@286 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
ohair@286 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ohair@286 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ohair@286 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
ohair@286 | 15 | * accompanied this code). |
ohair@286 | 16 | * |
ohair@286 | 17 | * You should have received a copy of the GNU General Public License version |
ohair@286 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
ohair@286 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ohair@286 | 20 | * |
ohair@286 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@286 | 22 | * or visit www.oracle.com if you need additional information or have any |
ohair@286 | 23 | * questions. |
ohair@286 | 24 | */ |
ohair@286 | 25 | |
ohair@286 | 26 | package javax.xml.bind.annotation; |
ohair@286 | 27 | |
ohair@286 | 28 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; |
ohair@286 | 29 | import static java.lang.annotation.RetentionPolicy.RUNTIME; |
ohair@286 | 30 | import static java.lang.annotation.ElementType.FIELD; |
ohair@286 | 31 | import static java.lang.annotation.ElementType.METHOD; |
ohair@286 | 32 | import java.lang.annotation.Retention; |
ohair@286 | 33 | import java.lang.annotation.Target; |
ohair@286 | 34 | |
ohair@286 | 35 | /** |
ohair@286 | 36 | * Generates a wrapper element around XML representation. |
ohair@286 | 37 | * |
ohair@286 | 38 | * This is primarily intended to be used to produce a wrapper |
ohair@286 | 39 | * XML element around collections. The annotation therefore supports |
ohair@286 | 40 | * two forms of serialization shown below. |
ohair@286 | 41 | * |
ohair@286 | 42 | * <pre> |
ohair@286 | 43 | * //Example: code fragment |
ohair@286 | 44 | * int[] names; |
ohair@286 | 45 | * |
ohair@286 | 46 | * // XML Serialization Form 1 (Unwrapped collection) |
ohair@286 | 47 | * <names> ... </names> |
ohair@286 | 48 | * <names> ... </names> |
ohair@286 | 49 | * |
ohair@286 | 50 | * // XML Serialization Form 2 ( Wrapped collection ) |
ohair@286 | 51 | * <wrapperElement> |
ohair@286 | 52 | * <names> value-of-item </names> |
ohair@286 | 53 | * <names> value-of-item </names> |
ohair@286 | 54 | * .... |
ohair@286 | 55 | * </wrapperElement> |
ohair@286 | 56 | * </pre> |
ohair@286 | 57 | * |
ohair@286 | 58 | * <p> The two serialized XML forms allow a null collection to be |
ohair@286 | 59 | * represented either by absence or presence of an element with a |
ohair@286 | 60 | * nillable attribute. |
ohair@286 | 61 | * |
ohair@286 | 62 | * <p> <b>Usage</b> </p> |
ohair@286 | 63 | * <p> |
ohair@286 | 64 | * The <tt>@XmlElementWrapper</tt> annotation can be used with the |
ohair@286 | 65 | * following program elements: |
ohair@286 | 66 | * <ul> |
ohair@286 | 67 | * <li> JavaBean property </li> |
ohair@286 | 68 | * <li> non static, non transient field </li> |
ohair@286 | 69 | * </ul> |
ohair@286 | 70 | * |
ohair@286 | 71 | * <p>The usage is subject to the following constraints: |
ohair@286 | 72 | * <ul> |
ohair@286 | 73 | * <li> The property must be a collection property </li> |
ohair@286 | 74 | * <li> This annotation can be used with the following annotations: |
ohair@286 | 75 | * {@link XmlElement}, |
ohair@286 | 76 | * {@link XmlElements}, |
ohair@286 | 77 | * {@link XmlElementRef}, |
ohair@286 | 78 | * {@link XmlElementRefs}, |
ohair@286 | 79 | * {@link XmlJavaTypeAdapter}.</li> |
ohair@286 | 80 | * </ul> |
ohair@286 | 81 | * |
ohair@286 | 82 | * <p>See "Package Specification" in javax.xml.bind.package javadoc for |
ohair@286 | 83 | * additional common information.</p> |
ohair@286 | 84 | * |
ohair@286 | 85 | * @author <ul><li>Kohsuke Kawaguchi, Sun Microsystems, Inc.</li><li>Sekhar Vajjhala, Sun Microsystems, Inc.</li></ul> |
ohair@286 | 86 | * @see XmlElement |
ohair@286 | 87 | * @see XmlElements |
ohair@286 | 88 | * @see XmlElementRef |
ohair@286 | 89 | * @see XmlElementRefs |
ohair@286 | 90 | * @since JAXB2.0 |
ohair@286 | 91 | * |
ohair@286 | 92 | */ |
ohair@286 | 93 | |
ohair@286 | 94 | @Retention(RUNTIME) @Target({FIELD, METHOD}) |
ohair@286 | 95 | public @interface XmlElementWrapper { |
ohair@286 | 96 | /** |
ohair@286 | 97 | * Name of the XML wrapper element. By default, the XML wrapper |
ohair@286 | 98 | * element name is derived from the JavaBean property name. |
ohair@286 | 99 | */ |
ohair@286 | 100 | String name() default "##default"; |
ohair@286 | 101 | |
ohair@286 | 102 | /** |
ohair@286 | 103 | * XML target namespace of the XML wrapper element. |
ohair@286 | 104 | * <p> |
ohair@286 | 105 | * If the value is "##default", then the namespace is determined |
ohair@286 | 106 | * as follows: |
ohair@286 | 107 | * <ol> |
ohair@286 | 108 | * <li> |
ohair@286 | 109 | * If the enclosing package has {@link XmlSchema} annotation, |
ohair@286 | 110 | * and its {@link XmlSchema#elementFormDefault() elementFormDefault} |
ohair@286 | 111 | * is {@link XmlNsForm#QUALIFIED QUALIFIED}, then the namespace of |
ohair@286 | 112 | * the enclosing class. |
ohair@286 | 113 | * |
ohair@286 | 114 | * <li> |
ohair@286 | 115 | * Otherwise "" (which produces unqualified element in the default |
ohair@286 | 116 | * namespace. |
ohair@286 | 117 | * </ol> |
ohair@286 | 118 | */ |
ohair@286 | 119 | String namespace() default "##default"; |
ohair@286 | 120 | |
ohair@286 | 121 | /** |
ohair@286 | 122 | * If true, the absence of the collection is represented by |
ohair@286 | 123 | * using <tt>xsi:nil='true'</tt>. Otherwise, it is represented by |
ohair@286 | 124 | * the absence of the element. |
ohair@286 | 125 | */ |
ohair@286 | 126 | boolean nillable() default false; |
ohair@286 | 127 | |
ohair@286 | 128 | /** |
ohair@286 | 129 | * Customize the wrapper element declaration to be required. |
ohair@286 | 130 | * |
ohair@286 | 131 | * <p> |
ohair@286 | 132 | * If required() is true, then the corresponding generated |
ohair@286 | 133 | * XML schema element declaration will have <tt>minOccurs="1"</tt>, |
ohair@286 | 134 | * to indicate that the wrapper element is always expected. |
ohair@286 | 135 | * |
ohair@286 | 136 | * <p> |
ohair@286 | 137 | * Note that this only affects the schema generation, and |
ohair@286 | 138 | * not the unmarshalling or marshalling capability. This is |
ohair@286 | 139 | * simply a mechanism to let users express their application constraints |
ohair@286 | 140 | * better. |
ohair@286 | 141 | * |
ohair@286 | 142 | * @since JAXB 2.1 |
ohair@286 | 143 | */ |
ohair@286 | 144 | boolean required() default false; |
ohair@286 | 145 | } |