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

changeset 286
f50545b5e2f1
child 397
b99d7e355d4b
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/jaxws_classes/javax/xml/bind/annotation/XmlID.java	Tue Mar 06 16:09:35 2012 -0800
     1.3 @@ -0,0 +1,94 @@
     1.4 +/*
     1.5 + * Copyright (c) 2004, 2010, 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 + * Maps a JavaBean property to XML ID.
    1.39 + *
    1.40 + * <p>
    1.41 + * To preserve referential integrity of an object graph across XML
    1.42 + * serialization followed by a XML deserialization, requires an object
    1.43 + * reference to be marshalled by reference or containment
    1.44 + * appropriately. Annotations <tt>&#64;XmlID</tt> and <tt>&#64;XmlIDREF</tt>
    1.45 + * together allow a customized mapping of a JavaBean property's
    1.46 + * type by containment or reference.
    1.47 + *
    1.48 + * <p><b>Usage</b> </p>
    1.49 + * The <tt>&#64;XmlID</tt> annotation can be used with the following
    1.50 + * program elements:
    1.51 + * <ul>
    1.52 + *   <li> a JavaBean property </li>
    1.53 + *   <li> non static, non transient field </li>
    1.54 + * </ul>
    1.55 + *
    1.56 + * <p>See "Package Specification" in javax.xml.bind.package javadoc for
    1.57 + * additional common information.</p>
    1.58 + *
    1.59 + * The usage is subject to the following constraints:
    1.60 + * <ul>
    1.61 + *   <li> At most one field or property in a class can be annotated
    1.62 + *        with <tt>&#64;XmlID</tt>.  </li>
    1.63 + *   <li> The JavaBean property's type must be <tt>java.lang.String</tt>.</li>
    1.64 + *   <li> The only other mapping annotations that can be used
    1.65 + *        with <tt>&#64;XmlID</tt>
    1.66 + *        are:<tt>&#64;XmlElement</tt> and <tt>&#64;XmlAttribute</tt>.</li>
    1.67 + * </ul>
    1.68 + *
    1.69 + * <p><b>Example</b>: Map a JavaBean property's type to <tt>xs:ID</tt></p>
    1.70 + * <pre>
    1.71 + *    // Example: code fragment
    1.72 + *    public class Customer {
    1.73 + *        &#64;XmlAttribute
    1.74 + *        &#64;XmlID
    1.75 + *        public String getCustomerID();
    1.76 + *        public void setCustomerID(String id);
    1.77 + *        .... other properties not shown
    1.78 + *    }
    1.79 + *
    1.80 + *    &lt;!-- Example: XML Schema fragment -->
    1.81 + *    &lt;xs:complexType name="Customer">
    1.82 + *      &lt;xs:complexContent>
    1.83 + *        &lt;xs:sequence>
    1.84 + *          ....
    1.85 + *        &lt;/xs:sequence>
    1.86 + *        &lt;xs:attribute name="customerID" type="xs:ID"/>
    1.87 + *      &lt;/xs:complexContent>
    1.88 + *    &lt;/xs:complexType>
    1.89 + * </pre>
    1.90 + *
    1.91 + * @author Sekhar Vajjhala, Sun Microsystems, Inc.
    1.92 + * @see XmlIDREF
    1.93 + * @since JAXB2.0
    1.94 + */
    1.95 +
    1.96 +@Retention(RUNTIME) @Target({FIELD, METHOD})
    1.97 +public @interface XmlID { }

mercurial