< prev index next >
src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlAnyElement.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -48,22 +48,21 @@
* single value JavaBean property. During unmarshalling, each xml element
* that does not match a static @XmlElement or @XmlElementRef
* annotation for the other JavaBean properties on the class, is added to this
* "catch-all" property.
*
- * <p>
* <h2>Usages:</h2>
* <pre>
* @XmlAnyElement
* public {@link Element}[] others;
*
* // Collection of {@link Element} or JAXB elements.
* @XmlAnyElement(lax="true")
* public {@link Object}[] others;
*
* @XmlAnyElement
- * private List<{@link Element}> nodes;
+ * private List<{@link Element}> nodes;
*
* @XmlAnyElement
* private {@link Element} node;
* </pre>
*
@@ -86,61 +85,61 @@
* <p>
* This annotation can be used with {@link XmlMixed} like this:
* <pre>
* // List of java.lang.String or DOM nodes.
* @XmlAnyElement @XmlMixed
- * List<Object> others;
+ * List<Object> others;
* </pre>
*
*
* <h2>Schema To Java example</h2>
*
* The following schema would produce the following Java class:
* <pre>
- * <xs:complexType name="foo">
- * <xs:sequence>
- * <xs:element name="a" type="xs:int" />
- * <xs:element name="b" type="xs:int" />
- * <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
- * </xs:sequence>
- * </xs:complexType>
+ * <xs:complexType name="foo">
+ * <xs:sequence>
+ * <xs:element name="a" type="xs:int" />
+ * <xs:element name="b" type="xs:int" />
+ * <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
+ * </xs:sequence>
+ * </xs:complexType>
* </pre>
*
* <pre>
* class Foo {
* int a;
* int b;
* @{@link XmlAnyElement}
- * List<Element> any;
+ * List<Element> any;
* }
* </pre>
*
* It can unmarshal instances like
*
* <pre>
- * <foo xmlns:e="extra">
- * <a>1</a>
- * <e:other /> // this will be bound to DOM, because unmarshalling is orderless
- * <b>3</b>
- * <e:other />
- * <c>5</c> // this will be bound to DOM, because the annotation doesn't remember namespaces.
- * </foo>
+ * <foo xmlns:e="extra">
+ * <a>1</a>
+ * <e:other /> // this will be bound to DOM, because unmarshalling is orderless
+ * <b>3</b>
+ * <e:other />
+ * <c>5</c> // this will be bound to DOM, because the annotation doesn't remember namespaces.
+ * </foo>
* </pre>
*
*
*
* The following schema would produce the following Java class:
* <pre>
- * <xs:complexType name="bar">
- * <xs:complexContent>
- * <xs:extension base="foo">
- * <xs:sequence>
- * <xs:element name="c" type="xs:int" />
- * <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
- * </xs:sequence>
- * </xs:extension>
- * </xs:complexType>
+ * <xs:complexType name="bar">
+ * <xs:complexContent>
+ * <xs:extension base="foo">
+ * <xs:sequence>
+ * <xs:element name="c" type="xs:int" />
+ * <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
+ * </xs:sequence>
+ * </xs:extension>
+ * </xs:complexType>
* </pre>
*
* <pre>
* class Bar extends Foo {
* int c;
@@ -150,18 +149,18 @@
*
*
* It can unmarshal instances like
*
* <pre>
- * <bar xmlns:e="extra">
- * <a>1</a>
- * <e:other /> // this will be bound to DOM, because unmarshalling is orderless
- * <b>3</b>
- * <e:other />
- * <c>5</c> // this now goes to Bar.c
- * <e:other /> // this will go to Foo.any
- * </bar>
+ * <bar xmlns:e="extra">
+ * <a>1</a>
+ * <e:other /> // this will be bound to DOM, because unmarshalling is orderless
+ * <b>3</b>
+ * <e:other />
+ * <c>5</c> // this now goes to Bar.c
+ * <e:other /> // this will go to Foo.any
+ * </bar>
* </pre>
*
*
*
*
@@ -171,47 +170,47 @@
* designate additional elements that can participate in the content tree.
*
* <p>
* The following schema would produce the following Java class:
* <pre>
- * <xs:complexType name="foo">
- * <xs:choice maxOccurs="unbounded" minOccurs="0">
- * <xs:element name="a" type="xs:int" />
- * <xs:element name="b" type="xs:int" />
- * <xs:any namespace="##other" processContents="lax" />
- * </xs:choice>
- * </xs:complexType>
+ * <xs:complexType name="foo">
+ * <xs:choice maxOccurs="unbounded" minOccurs="0">
+ * <xs:element name="a" type="xs:int" />
+ * <xs:element name="b" type="xs:int" />
+ * <xs:any namespace="##other" processContents="lax" />
+ * </xs:choice>
+ * </xs:complexType>
* </pre>
*
* <pre>
* class Foo {
* @{@link XmlAnyElement}(lax="true")
* @{@link XmlElementRefs}({
* @{@link XmlElementRef}(name="a", type="JAXBElement.class")
* @{@link XmlElementRef}(name="b", type="JAXBElement.class")
* })
- * {@link List}<{@link Object}> others;
+ * {@link List}<{@link Object}> others;
* }
*
* @XmlRegistry
* class ObjectFactory {
* ...
* @XmlElementDecl(name = "a", namespace = "", scope = Foo.class)
- * {@link JAXBElement}<Integer> createFooA( Integer i ) { ... }
+ * {@link JAXBElement}<Integer> createFooA( Integer i ) { ... }
*
* @XmlElementDecl(name = "b", namespace = "", scope = Foo.class)
- * {@link JAXBElement}<Integer> createFooB( Integer i ) { ... }
+ * {@link JAXBElement}<Integer> createFooB( Integer i ) { ... }
* </pre>
*
* It can unmarshal instances like
*
* <pre>
- * <foo xmlns:e="extra">
- * <a>1</a> // this will unmarshal to a {@link JAXBElement} instance whose value is 1.
- * <e:other /> // this will unmarshal to a DOM {@link Element}.
- * <b>3</b> // this will unmarshal to a {@link JAXBElement} instance whose value is 1.
- * </foo>
+ * <foo xmlns:e="extra">
+ * <a>1</a> // this will unmarshal to a {@link JAXBElement} instance whose value is 1.
+ * <e:other /> // this will unmarshal to a DOM {@link Element}.
+ * <b>3</b> // this will unmarshal to a {@link JAXBElement} instance whose value is 1.
+ * </foo>
* </pre>
*
*
*
*
@@ -225,14 +224,14 @@
* public {@link Object}[] others;
* }
* </pre>
* then the following document will unmarshal like this:
* <pre>
- * <foo>
- * <unknown />
- * <foo />
- * </foo>
+ * <foo>
+ * <unknown />
+ * <foo />
+ * </foo>
*
* Foo foo = unmarshal();
* // 1 for 'unknown', another for 'foo'
* assert foo.others.length==2;
* // 'unknown' unmarshals to a DOM element
< prev index next >