< 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&lt;String> createFoo(String s) { ... } * } * </pre> * <pre> ! * &lt;!-- XML input --> ! * &lt;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" * ! * &lt;!-- Example: XML schema definition --> ! * &lt;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&lt;String&gt; createFoo(String s) { ... } * } * </pre> * <pre> ! * &lt;!-- XML input --&gt; ! * &lt;foo&gt;string&lt;/foo&gt; * * // Example: code fragment corresponding to XML input ! * JAXBElement&lt;String&gt; o = ! * (JAXBElement&lt;String&gt;)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" * ! * &lt;!-- Example: XML schema definition --&gt; ! * &lt;xs:element name="foo" type="xs:string"/&gt; * </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> ! * &lt;!-- Example: XML schema definition --> ! * &lt;xs:schema> ! * &lt;xs:complexType name="pea"> ! * &lt;xs:choice maxOccurs="unbounded"> ! * &lt;xs:element name="foo" type="xs:string"/> ! * &lt;xs:element name="bar" type="xs:string"/> ! * &lt;/xs:choice> ! * &lt;/xs:complexType> ! * &lt;xs:element name="foo" type="xs:int"/> ! * &lt;/xs:schema> * </pre> * <pre> * // Example: expected default binding * class Pea { * @XmlElementRefs({ * @XmlElementRef(name="foo",type=JAXBElement.class) * @XmlElementRef(name="bar",type=JAXBElement.class) * }) ! * List&lt;JAXBElement&lt;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> ! * &lt;!-- Example: XML schema definition --&gt; ! * &lt;xs:schema&gt; ! * &lt;xs:complexType name="pea"&gt; ! * &lt;xs:choice maxOccurs="unbounded"&gt; ! * &lt;xs:element name="foo" type="xs:string"/&gt; ! * &lt;xs:element name="bar" type="xs:string"/&gt; ! * &lt;/xs:choice&gt; ! * &lt;/xs:complexType&gt; ! * &lt;xs:element name="foo" type="xs:int"/&gt; ! * &lt;/xs:schema&gt; * </pre> * <pre> * // Example: expected default binding * class Pea { * @XmlElementRefs({ * @XmlElementRef(name="foo",type=JAXBElement.class) * @XmlElementRef(name="bar",type=JAXBElement.class) * }) ! * List&lt;JAXBElement&lt;String&gt;&gt; fooOrBar; * } * * @XmlRegistry * class ObjectFactory { * @XmlElementDecl(scope=Pea.class,name="foo") ! * JAXBElement&lt;String&gt; createPeaFoo(String s); * * @XmlElementDecl(scope=Pea.class,name="bar") ! * JAXBElement&lt;String&gt; createPeaBar(String s); * * @XmlElementDecl(name="foo") ! * JAXBElement&lt;Integer&gt; 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 >