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

Tue, 09 Apr 2013 14:51:13 +0100

author
alanb
date
Tue, 09 Apr 2013 14:51:13 +0100
changeset 368
0989ad8c0860
parent 286
f50545b5e2f1
child 397
b99d7e355d4b
permissions
-rw-r--r--

8010393: Update JAX-WS RI to 2.2.9-b12941
Reviewed-by: alanb, erikj
Contributed-by: miroslav.kos@oracle.com, martin.grebac@oracle.com

     1 /*
     2  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     8  * particular file as subject to the "Classpath" exception as provided
     9  * by Oracle in the LICENSE file that accompanied this code.
    10  *
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    14  * version 2 for more details (a copy is included in the LICENSE file that
    15  * accompanied this code).
    16  *
    17  * You should have received a copy of the GNU General Public License version
    18  * 2 along with this work; if not, write to the Free Software Foundation,
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    20  *
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22  * or visit www.oracle.com if you need additional information or have any
    23  * questions.
    24  */
    26 package javax.xml.bind.annotation;
    28 import java.lang.annotation.Target;
    29 import java.lang.annotation.Retention;
    30 import static java.lang.annotation.ElementType.*;
    31 import static java.lang.annotation.RetentionPolicy.*;
    33 /**
    34  * <p>
    35  * Maps a JavaBean property to XML ID.
    36  *
    37  * <p>
    38  * To preserve referential integrity of an object graph across XML
    39  * serialization followed by a XML deserialization, requires an object
    40  * reference to be marshalled by reference or containment
    41  * appropriately. Annotations <tt>&#64;XmlID</tt> and <tt>&#64;XmlIDREF</tt>
    42  * together allow a customized mapping of a JavaBean property's
    43  * type by containment or reference.
    44  *
    45  * <p><b>Usage</b> </p>
    46  * The <tt>&#64;XmlID</tt> annotation can be used with the following
    47  * program elements:
    48  * <ul>
    49  *   <li> a JavaBean property </li>
    50  *   <li> non static, non transient field </li>
    51  * </ul>
    52  *
    53  * <p>See "Package Specification" in javax.xml.bind.package javadoc for
    54  * additional common information.</p>
    55  *
    56  * The usage is subject to the following constraints:
    57  * <ul>
    58  *   <li> At most one field or property in a class can be annotated
    59  *        with <tt>&#64;XmlID</tt>.  </li>
    60  *   <li> The JavaBean property's type must be <tt>java.lang.String</tt>.</li>
    61  *   <li> The only other mapping annotations that can be used
    62  *        with <tt>&#64;XmlID</tt>
    63  *        are:<tt>&#64;XmlElement</tt> and <tt>&#64;XmlAttribute</tt>.</li>
    64  * </ul>
    65  *
    66  * <p><b>Example</b>: Map a JavaBean property's type to <tt>xs:ID</tt></p>
    67  * <pre>
    68  *    // Example: code fragment
    69  *    public class Customer {
    70  *        &#64;XmlAttribute
    71  *        &#64;XmlID
    72  *        public String getCustomerID();
    73  *        public void setCustomerID(String id);
    74  *        .... other properties not shown
    75  *    }
    76  *
    77  *    &lt;!-- Example: XML Schema fragment -->
    78  *    &lt;xs:complexType name="Customer">
    79  *      &lt;xs:complexContent>
    80  *        &lt;xs:sequence>
    81  *          ....
    82  *        &lt;/xs:sequence>
    83  *        &lt;xs:attribute name="customerID" type="xs:ID"/>
    84  *      &lt;/xs:complexContent>
    85  *    &lt;/xs:complexType>
    86  * </pre>
    87  *
    88  * @author Sekhar Vajjhala, Sun Microsystems, Inc.
    89  * @see XmlIDREF
    90  * @since JAXB2.0
    91  */
    93 @Retention(RUNTIME) @Target({FIELD, METHOD})
    94 public @interface XmlID { }

mercurial