Java Doc for XmlElementDecl.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 Reference  Class Diagram Java Document (Java Doc) 


javax.xml.bind.annotation.XmlElementDecl

XmlElementDecl
public @interface XmlElementDecl(Code)
Maps a factory method to a XML element.

Usage

The annotation creates a mapping between an XML schema element declaration and a element factory method that returns a JAXBElement instance representing the element declaration. Typically, the element factory method is generated (and annotated) from a schema into the ObjectFactory class in a Java package that represents the binding of the element declaration's target namespace. Thus, while the annotation syntax allows @XmlElementDecl to be used on any method, semantically its use is restricted to annotation of element factory method. The usage is subject to the following constraints:
  • The class containing the element factory method annotated with @XmlElementDecl must be marked with XmlRegistry .
  • The element factory method must take one parameter assignable to Object .

Example 1: Annotation on a factory method

 // Example: code fragment
 @XmlRegistry
 class ObjectFactory {
 @XmlElementDecl(name="foo")
 JAXBElement<String> createFoo(String s) { ... }
 }
 
 
 <!-- XML input -->
 <foo>string</foo>
 // Example: code fragment corresponding to XML input
 JAXBElement<String> o =
 (JAXBElement<String>)unmarshaller.unmarshal(aboveDocument);
 // print JAXBElement instance to show values
 System.out.println(o.getName());   // prints  "{}foo"
 System.out.println(o.getValue());  // prints  "string"
 System.out.println(o.getValue().getClass()); // prints "java.lang.String"
 <!-- Example: XML schema definition -->
 <xs:element name="foo" type="xs:string"/>
 

Example 2: Element declaration with non local scope

The following example illustrates the use of scope annotation parameter in binding of element declaration in schema derived code.

The following example may be replaced in a future revision of this javadoc.


 <!-- Example: XML schema definition -->
 <xs:schema>
 <xs:complexType name="pea">
 <xs:choice maxOccurs="unbounded">
 <xs:element name="foo" type="xs:string"/>
 <xs:element name="bar" type="xs:string"/>
 </xs:choice>
 </xs:complexType> 
 <xs:element name="foo" type="xs:int"/>
 </xs:schema>
 
 // Example: expected default binding
 class Pea {
 @XmlElementRefs({
 @XmlElementRef(name="foo",type=JAXBElement.class)
 @XmlElementRef(name="bar",type=JAXBElement.class)
 })
 List<JAXBElement<String>> fooOrBar;
 }
 @XmlRegistry
 class ObjectFactory {
 @XmlElementDecl(scope=Pea.class,name="foo")
 JAXBElement createPeaFoo(String s);
 @XmlElementDecl(scope=Pea.class,name="bar")
 JAXBElement createPeaBar(String s);
 @XmlElementDecl(name="foo")
 JAXBElement createFoo(Integer i);
 }
 
Without scope createFoo and createPeaFoo would become ambiguous since both of them map to a XML schema element with the same local name "foo".
See Also:   XmlRegistry
since:
   JAXB 2.0


Field Summary
final public  Type DeclarationGLOBAL
     Used in XmlElementDecl.scope to signal that the declaration is in the global scope.
 StringdefaultValue
     Default value of this element.
 Stringname
     local name of the XML element.
 Stringnamespace
     namespace name of the XML element.
 Classscope
     scope of the mapping.
 StringsubstitutionHeadName
     XML local name of a substitution group's head element.
 StringsubstitutionHeadNamespace
     namespace name of a substitution group's head XML element.

This specifies the namespace name of the XML element whose local name is specified by substitutionHeadName().

If susbtitutionHeadName() is "", then this value can only be "##default".




Field Detail
GLOBAL
final public Type Declaration GLOBAL(Code)
Used in XmlElementDecl.scope to signal that the declaration is in the global scope.



defaultValue
String defaultValue(Code)
Default value of this element.

The '\u0000' value specified as a default of this annotation element is used as a poor-man's substitute for null to allow implementations to recognize the 'no default value' state.




name
String name(Code)
local name of the XML element.

Note to reviewers: There is no default name; since the annotation is on a factory method, it is not clear that the method name can be derived from the factory method name.
See Also:   XmlElementDecl.namespace()




namespace
String namespace(Code)
namespace name of the XML element.

If the value is "##default", then the value is the namespace name for the package of the class containing this factory method.
See Also:   XmlElementDecl.name()




scope
Class scope(Code)
scope of the mapping.

If this is not XmlElementDecl.GLOBAL , then this element declaration mapping is only active within the specified class.




substitutionHeadName
String substitutionHeadName(Code)
XML local name of a substitution group's head element.

If the value is "", then this element is not part of any substitution group.
See Also:   XmlElementDecl.substitutionHeadNamespace()




substitutionHeadNamespace
String substitutionHeadNamespace(Code)
namespace name of a substitution group's head XML element.

This specifies the namespace name of the XML element whose local name is specified by substitutionHeadName().

If susbtitutionHeadName() is "", then this value can only be "##default". But the value is ignored since since this element is not part of susbtitution group when the value of susbstitutionHeadName() is "".

If susbtitutionHeadName() is not "" and the value is "##default", then the namespace name is the namespace name to which the package of the containing class, marked with XmlRegistry , is mapped.

If susbtitutionHeadName() is not "" and the value is not "##default", then the value is the namespace name.
See Also:   XmlElementDecl.substitutionHeadName()






www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.