< prev index next >
src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlElementDecl.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 60,86 ****
* <pre>
* // Example: code fragment
* @XmlRegistry
* class ObjectFactory {
* @XmlElementDecl(name="foo")
! * JAXBElement<String> createFoo(String s) { ... }
* }
* </pre>
* <pre>
! * <!-- 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"/>
* </pre>
*
* <p><b>Example 2: </b> Element declaration with non local scope
* <p>
* The following example illustrates the use of scope annotation
--- 60,86 ----
* <pre>
* // Example: code fragment
* @XmlRegistry
* class ObjectFactory {
* @XmlElementDecl(name="foo")
! * JAXBElement<String> createFoo(String s) { ... }
* }
* </pre>
* <pre>
! * <!-- 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"/>
* </pre>
*
* <p><b>Example 2: </b> Element declaration with non local scope
* <p>
* The following example illustrates the use of scope annotation
*** 89,129 ****
* <p>
* The following example may be replaced in a future revision of
* this javadoc.
*
* <pre>
! * <!-- 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>
* </pre>
* <pre>
* // 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<String> createPeaFoo(String s);
*
* @XmlElementDecl(scope=Pea.class,name="bar")
! * JAXBElement<String> createPeaBar(String s);
*
* @XmlElementDecl(name="foo")
! * JAXBElement<Integer> createFoo(Integer i);
* }
*
* </pre>
* Without scope createFoo and createPeaFoo would become ambiguous
* since both of them map to a XML schema element with the same local
--- 89,129 ----
* <p>
* The following example may be replaced in a future revision of
* this javadoc.
*
* <pre>
! * <!-- 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>
* </pre>
* <pre>
* // 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<String> createPeaFoo(String s);
*
* @XmlElementDecl(scope=Pea.class,name="bar")
! * JAXBElement<String> createPeaBar(String s);
*
* @XmlElementDecl(name="foo")
! * JAXBElement<Integer> createFoo(Integer i);
* }
*
* </pre>
* Without scope createFoo and createPeaFoo would become ambiguous
* since both of them map to a XML schema element with the same local
< prev index next >