Source Code Cross Referenced for XmlIDREF.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.Target;
009:        import java.lang.annotation.Retention;
010:        import static java.lang.annotation.ElementType.*;
011:        import static java.lang.annotation.RetentionPolicy.*;
012:
013:        /**
014:         * <p>
015:         * Maps a JavaBean property to XML IDREF.
016:         * 
017:         * <p>
018:         * To preserve referential integrity of an object graph across XML
019:         * serialization followed by a XML deserialization, requires an object
020:         * reference to be marshalled by reference or containment
021:         * appropriately. Annotations <tt>&#64;XmlID</tt> and <tt>&#64;XmlIDREF</tt>
022:         * together allow a customized mapping of a JavaBean property's
023:         * type by containment or reference. 
024:         *
025:         * <p><b>Usage</b> </p>
026:         * The <tt>&#64;XmlIDREF</tt> annotation can be used with the following
027:         * program elements: 
028:         * <ul> 
029:         *   <li> a JavaBean property </li>
030:         *   <li> non static, non transient field </li>
031:         * </ul>
032:         * 
033:         * <p>See "Package Specification" in javax.xml.bind.package javadoc for
034:         * additional common information.</p>
035:         *
036:         * <p> The usage is subject to the following constraints:
037:         * <ul>
038:         *
039:         *   <li> If the type of the field or property is a collection type,
040:         *        then the collection item type must contain a property or
041:         *        field annotated with <tt>&#64;XmlID</tt>.  </li> 
042:         *   <li> If the field or property is single valued, then the type of
043:         *        the property or field must contain a property or field
044:         *        annotated with <tt>&#64;XmlID</tt>.
045:         *        <p>Note: If the collection item type or the type of the
046:         *        property (for non collection type) is java.lang.Object, then
047:         *        the instance must contain a property/field annotated with
048:         *        <tt>&#64;XmlID</tt> attribute.  
049:         *        </li>
050:         *   <li> This annotation can be used with the following annotations:
051:         *        {@link XmlElement}, {@link XmlAttribute}, {@link XmlList}, 
052:         *        and {@link XmlElements}.</li>  
053:         *
054:         * </ul>
055:         * <p><b>Example:</b> Map a JavaBean property to <tt>xs:IDREF</tt>
056:         *   (i.e. by reference rather than by containment)</p>
057:         * <pre>
058:         *
059:         *   //EXAMPLE: Code fragment
060:         *   public class Shipping {
061:         *       &#64;XmlIDREF public Customer getCustomer();
062:         *       public void setCustomer(Customer customer);
063:         *       ....
064:         *    }
065:         *
066:         *   &lt;!-- Example: XML Schema fragment -->
067:         *   &lt;xs:complexType name="Shipping">
068:         *     &lt;xs:complexContent>
069:         *       &lt;xs:sequence>
070:         *         &lt;xs:element name="customer" type="xs:IDREF"/>
071:         *         ....
072:         *       &lt;/xs:sequence>
073:         *     &lt;/xs:complexContent>
074:         *   &lt;/xs:complexType>
075:         *
076:         * </pre>
077:         *
078:         *
079:         * <p><b>Example 2: </b> The following is a complete example of
080:         * containment versus reference.
081:         * 
082:         * <pre>
083:         *    // By default, Customer maps to complex type <tt>xs:Customer</tt>
084:         *    public class Customer {
085:         *        
086:         *        // map JavaBean property type to <tt>xs:ID</tt>
087:         *        &#64;XmlID public String getCustomerID();
088:         *        public void setCustomerID(String id);
089:         *
090:         *        // .... other properties not shown 
091:         *    }
092:         *
093:         *
094:         *   // By default, Invoice maps to a complex type <tt>xs:Invoice</tt> 
095:         *   public class Invoice {
096:         *    
097:         *       // map by reference
098:         *       &#64;XmlIDREF public Customer getCustomer();       
099:         *       public void setCustomer(Customer customer);
100:         *
101:         *      // .... other properties not shown here
102:         *   }
103:         *
104:         *   // By default, Shipping maps to complex type <tt>xs:Shipping</tt>
105:         *   public class Shipping {
106:         *
107:         *       // map by reference
108:         *       &#64;XmlIDREF public Customer getCustomer();       
109:         *       public void setCustomer(Customer customer);
110:         *   }
111:         *
112:         *   // at least one class must reference Customer by containment;
113:         *   // Customer instances won't be marshalled.
114:         *   &#64;XmlElement(name="CustomerData")
115:         *   public class CustomerData {
116:         *       // map reference to Customer by containment by default.
117:         *       public Customer getCustomer();
118:         *
119:         *       // maps reference to Shipping by containment by default. 
120:         *       public Shipping getShipping();     
121:         *
122:         *       // maps reference to Invoice by containment by default. 
123:         *       public Invoice getInvoice();     
124:         *   }
125:         *
126:         *   &lt;!-- XML Schema mapping for above code frament -->
127:         *
128:         *   &lt;xs:complexType name="Invoice">
129:         *     &lt;xs:complexContent>
130:         *       &lt;xs:sequence>
131:         *         &lt;xs:element name="customer" type="xs:IDREF"/>
132:         *         ....
133:         *       &lt;/xs:sequence>
134:         *     &lt;/xs:complexContent>
135:         *   &lt;/xs:complexType>
136:         *
137:         *   &lt;xs:complexType name="Shipping">
138:         *     &lt;xs:complexContent>
139:         *       &lt;xs:sequence>
140:         *         &lt;xs:element name="customer" type="xs:IDREF"/>
141:         *         ....
142:         *       &lt;/xs:sequence>
143:         *     &lt;/xs:complexContent>
144:         *   &lt;/xs:complexType>
145:         *
146:         *   &lt;xs:complexType name="Customer">
147:         *     &lt;xs:complexContent>
148:         *       &lt;xs:sequence>
149:         *         ....
150:         *       &lt;/xs:sequence>
151:         *       &lt;xs:attribute name="CustomerID" type="xs:ID"/>
152:         *     &lt;/xs:complexContent>
153:         *   &lt;/xs:complexType>
154:         *
155:         *   &lt;xs:complexType name="CustomerData">
156:         *     &lt;xs:complexContent>
157:         *       &lt;xs:sequence>
158:         *         &lt;xs:element name="customer" type="xs:Customer"/>
159:         *         &lt;xs:element name="shipping" type="xs:Shipping"/>
160:         *         &lt;xs:element name="invoice"  type="xs:Invoice"/>
161:         *       &lt;/xs:sequence>
162:         *     &lt;/xs:complexContent>
163:         *   &lt;/xs:complexType>
164:         *
165:         *   &lt;xs:element name"customerData" type="xs:CustomerData"/>
166:         *
167:         *   &lt;!-- Instance document conforming to the above XML Schema -->
168:         *    &lt;customerData>
169:         *       &lt;customer customerID="Alice">
170:         *           ....
171:         *       &lt;/customer>
172:         *
173:         *       &lt;shipping customer="Alice">
174:         *           ....
175:         *       &lt;/shipping>
176:         *         
177:         *       &lt;invoice customer="Alice">
178:         *           ....
179:         *       &lt;/invoice>
180:         *   &lt;/customerData>
181:         *
182:         * </pre>
183:         *
184:         * <p><b>Example 3: </b> Mapping List to repeating element of type IDREF
185:         * <pre>
186:         *     // Code fragment
187:         *     public class Shipping {
188:         *         &#64;XmlIDREF
189:         *         &#64;XmlElement(name="Alice")
190:         *             public List customers;
191:         *     }
192:         *
193:         *     &lt;!-- XML schema fragment -->
194:         *     &lt;xs:complexType name="Shipping">
195:         *       &lt;xs:sequence>
196:         *         &lt;xs:choice minOccurs="0" maxOccurs="unbounded">
197:         *           &lt;xs:element name="Alice" type="xs:IDREF"/>
198:         *         &lt;/xs:choice>
199:         *       &lt;/xs:sequence>
200:         *     &lt;/xs:complexType> 
201:         * </pre>
202:         *
203:         * <p><b>Example 4: </b> Mapping a List to a list of elements of type IDREF.
204:         * <pre>
205:         *     //Code fragment
206:         *     public class Shipping {
207:         *         &#64;XmlIDREF
208:         *         &#64;XmlElements(
209:         *             &#64;XmlElement(name="Alice", type="Customer.class")
210:         *              &#64;XmlElement(name="John", type="InternationalCustomer.class")
211:         *         public List customers;
212:         *     }
213:         *
214:         *     &lt;!-- XML Schema fragment -->
215:         *     &lt;xs:complexType name="Shipping">
216:         *       &lt;xs:sequence>
217:         *         &lt;xs:choice minOccurs="0" maxOccurs="unbounded">
218:         *           &lt;xs:element name="Alice" type="xs:IDREF"/>
219:         *           &lt;xs:element name="John" type="xs:IDREF"/>
220:         *         &lt;/xs:choice>
221:         *       &lt;/xs:sequence>
222:         *     &lt;/xs:complexType> 
223:         * </pre>
224:         * @author Sekhar Vajjhala, Sun Microsystems, Inc. 
225:         * @see XmlID
226:         * @since JAXB2.0
227:         * @version $Revision: 1.12 $
228:         */
229:
230:        @Retention(RUNTIME)
231:        @Target({FIELD,METHOD})
232:        public @interface XmlIDREF {
233:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.