KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > xml > bind > annotation > XmlTransient


1 /*
2  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
3  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
4  */

5
6 package javax.xml.bind.annotation;
7
8 import java.lang.annotation.Target JavaDoc;
9 import java.lang.annotation.Retention JavaDoc;
10 import static java.lang.annotation.ElementType JavaDoc.*;
11 import static java.lang.annotation.RetentionPolicy JavaDoc.*;
12
13 /**
14  * <p>
15  * Prevents the mapping of a JavaBean property/type to XML representation.
16  * <p>
17  * The <tt>@XmlTransient</tt> annotation is useful for resolving name
18  * collisions between a JavaBean property name and a field name or
19  * preventing the mapping of a field/property. A name collision can
20  * occur when the decapitalized JavaBean property name and a field
21  * name are the same. If the JavaBean property refers to the field,
22  * then the name collision can be resolved by preventing the
23  * mapping of either the field or the JavaBean property using the
24  * <tt>@XmlTransient</tt> annotation.
25  *
26  * <p>
27  * When placed on a class, it indicates that the class shouldn't be mapped
28  * to XML by itself. Properties on such class will be mapped to XML along
29  * with its derived classes, as if the class is inlined.
30  *
31  * <p><b>Usage</b></p>
32  * <p> The <tt>@XmlTransient</tt> annotation can be used with the following
33  * program elements:
34  * <ul>
35  * <li> a JavaBean property </li>
36  * <li> field </li>
37  * <li> class </li>
38  * </ul>
39  *
40  * <p><tt>@XmlTransient</tt>is mutually exclusive with all other
41  * JAXB defined annotations. </p>
42  *
43  * <p>See "Package Specification" in javax.xml.bind.package javadoc for
44  * additional common information.</p>
45  *
46  * <p><b>Example:</b> Resolve name collision between JavaBean property and
47  * field name </p>
48  *
49  * <pre>
50  * // Example: Code fragment
51  * public class USAddress {
52  *
53  * // The field name "name" collides with the property name
54  * // obtained by bean decapitalization of getName() below
55  * &#64;XmlTransient public String name;
56  *
57  * String getName() {..};
58  * String setName() {..};
59  * }
60  *
61  *
62  * &lt;!-- Example: XML Schema fragment -->
63  * &lt;xs:complexType name="USAddress">
64  * &lt;xs:sequence>
65  * &lt;xs:element name="name" type="xs:string"/>
66  * &lt;/xs:sequence>
67  * &lt;/xs:complexType>
68  * </pre>
69  *
70  * @author Sekhar Vajjhala, Sun Microsystems, Inc.
71  * @since JAXB2.0
72  * @version $Revision$
73  */

74
75 @Retention JavaDoc(RUNTIME) @Target JavaDoc({FIELD, METHOD, TYPE})
76 public @interface XmlTransient {}
77    
78
Popular Tags