Source Code Cross Referenced for XmlRootElement.java in  » 6.0-JDK-Modules » jaxb-api » javax » xml » bind » annotation » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » jaxb api » javax.xml.bind.annotation 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
003:         * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
004:         */
005:
006:        package javax.xml.bind.annotation;
007:
008:        import java.lang.annotation.Retention;
009:        import java.lang.annotation.Target;
010:
011:        import static java.lang.annotation.RetentionPolicy.RUNTIME;
012:        import static java.lang.annotation.ElementType.TYPE;
013:
014:        /**
015:         * Maps a class or an enum type to an XML element.
016:         *
017:         * <p> <b>Usage</b> </p>
018:         * <p>
019:         * The &#64;XmlRootElement annotation can be used with the following program
020:         * elements: 
021:         * <ul> 
022:         *   <li> a top level class </li>
023:         *   <li> an enum type </li>
024:         * </ul>
025:         *
026:         * <p>See "Package Specification" in javax.xml.bind.package javadoc for
027:         * additional common information.</p>
028:         * 
029:         * <p>
030:         * When a top level class or an enum type is annotated with the 
031:         * &#64;XmlRootElement annotation, then its value is represented 
032:         * as XML element in an XML document.
033:         *
034:         * <p> This annotation can be used with the following annotations:
035:         * {@link XmlType}, {@link XmlEnum}, {@link XmlAccessorType}, 
036:         * {@link XmlAccessorOrder}.
037:         * <p>
038:
039:         * <p>
040:         * <b>Example 1: </b> Associate an element with XML Schema type
041:         * <pre>
042:         *     // Example: Code fragment
043:         *     &#64;XmlRootElement
044:         *     class Point {
045:         *        int x;
046:         *        int y;
047:         *        Point(int _x,int _y) {x=_x;y=_y;}
048:         *     }
049:         * </pre>
050:         *
051:         * <pre>
052:         *     //Example: Code fragment corresponding to XML output
053:         *     marshal( new Point(3,5), System.out);
054:         * </pre>
055:         *
056:         * <pre><xmp>
057:         *     <!-- Example: XML output -->
058:         *     <point>
059:         *       <x> 3 </x>
060:         *       <y> 5 </y>
061:         *     </point>
062:         * </xmp></pre>
063:         *
064:         * The annotation causes an global element declaration to be produced
065:         * in the schema. The global element declaration is associated with
066:         * the XML schema type to which the class is mapped.
067:         *
068:         * <pre><xmp>
069:         *     <!-- Example: XML schema definition -->
070:         *     <xs:element name="point" type="point"/>
071:         *     <xs:complexType name="point">
072:         *       <xs:sequence>
073:         *         <xs:element name="x" type="xs:int"/>
074:         *         <xs:element name="y" type="xs:int"/>
075:         *       </xs:sequence>
076:         *     </xs:complexType>
077:         * </xmp></pre>
078:         *
079:         * <p>
080:         *
081:         * <b>Example 2: Orthogonality to type inheritance </b>
082:         * 
083:         * <p>
084:         * An element declaration annotated on a type is not inherited by its
085:         * derived types. The following example shows this.
086:         * <pre>
087:         *     // Example: Code fragment
088:         *     &#64;XmlRootElement
089:         *     class Point3D extends Point {
090:         *         int z;
091:         *         Point3D(int _x,int _y,int _z) {super(_x,_y);z=_z;}
092:         *     }
093:         *
094:         *     //Example: Code fragment corresponding to XML output * 
095:         *     marshal( new Point3D(3,5,0), System.out );
096:         *
097:         *     &lt;!-- Example: XML output -->
098:         *     &lt;!-- The element name is point3D not point -->
099:         *     &lt;point3D>
100:         *       &lt;x>3&lt;/x>
101:         *       &lt;y>5&lt;/y>
102:         *       &lt;z>0&lt;/z>
103:         *     &lt;/point3D>
104:         *
105:         *     &lt;!-- Example: XML schema definition -->
106:         *     &lt;xs:element name="point3D" type="point3D"/>
107:         *     &lt;xs:complexType name="point3D">
108:         *       &lt;xs:complexContent>
109:         *         &lt;xs:extension base="point">
110:         *           &lt;xs:sequence>
111:         *             &lt;xs:element name="z" type="xs:int"/>
112:         *           &lt;/xs:sequence>
113:         *         &lt;/xs:extension>
114:         *       &lt;/xs:complexContent>
115:         *     &lt;/xs:complexType>
116:         * </pre>
117:         *
118:         * <b>Example 3: </b> Associate a global element with XML Schema type
119:         * to which the class is mapped.
120:         * <pre>
121:         *     //Example: Code fragment
122:         *     &#64;XmlRootElement(name="PriceElement")
123:         *     public class USPrice {
124:         *         &#64;XmlElement
125:         *         public java.math.BigDecimal price;
126:         *     }
127:         *
128:         *     &lt;!-- Example: XML schema definition -->
129:         *     &lt;xs:element name="PriceElement" type="USPrice"/>
130:         *     &lt;xs:complexType name="USPrice">
131:         *       &lt;xs:sequence>
132:         *         &lt;xs:element name="price" type="xs:decimal"/>
133:         *       &lt;/sequence>
134:         *     &lt;/xs:complexType>
135:         * </pre>
136:         *
137:         * @author Sekhar Vajjhala, Sun Microsystems, Inc.
138:         * @since JAXB2.0
139:         */
140:        @Retention(RUNTIME)
141:        @Target({TYPE})
142:        public @interface XmlRootElement {
143:            /**
144:             * namespace name of the XML element.
145:             * <p>
146:             * If the value is "##default", then the XML namespace name is derived
147:             * from the package of the class ( {@link XmlSchema} ). If the
148:             * package is unnamed, then the XML namespace is the default empty
149:             * namespace.
150:             */
151:            String namespace() default "##default";
152:
153:            /**
154:             * local name of the XML element.
155:             * <p>
156:             * If the value is "##default", then the name is derived from the
157:             * class name. 
158:             *
159:             */
160:            String name() default "##default";
161:
162:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.