1 package javax.xml.bind.annotation; 2 3 import java.lang.annotation.Retention; 4 import java.lang.annotation.Target; 5 import static java.lang.annotation.RetentionPolicy.RUNTIME; 6 import static java.lang.annotation.ElementType.FIELD; 7 import static java.lang.annotation.ElementType.METHOD; 8 import static java.lang.annotation.ElementType.PARAMETER; 9 10 /** 11 * Used to map a property to a list simple type. 12 * 13 * <p><b>Usage</b> </p> 14 * <p> 15 * The <tt>@XmlList</tt> annotation can be used with the 16 * following program elements: 17 * <ul> 18 * <li> JavaBean property </li> 19 * <li> field </li> 20 * </ul> 21 * 22 * <p> 23 * When a collection property is annotated just with @XmlElement, 24 * each item in the collection will be wrapped by an element. 25 * For example, 26 * 27 * <pre> 28 * @XmlRootElement 29 * class Foo { 30 * @XmlElement 31 * List<String> data; 32 * } 33 * </pre> 34 * 35 * would produce XML like this: 36 * 37 * <pre><xmp> 38 * <foo> 39 * <data>abc</data> 40 * <data>def</data> 41 * </foo> 42 * </xmp></pre> 43 * 44 * @XmlList annotation, on the other hand, allows multiple values to be 45 * represented as whitespace-separated tokens in a single element. For example, 46 * 47 * <pre> 48 * @XmlRootElement 49 * class Foo { 50 * @XmlElement 51 * @XmlList 52 * List<String> data; 53 * } 54 * </pre> 55 * 56 * the above code will produce XML like this: 57 * 58 * <pre><xmp> 59 * <foo> 60 * <data>abc def</data> 61 * </foo> 62 * </xmp></pre> 63 * 64 * <p>This annotation can be used with the following annotations: 65 * {@link XmlElement}, 66 * {@link XmlAttribute}, 67 * {@link XmlValue}, 68 * {@link XmlIDREF}. 69 * <ul> 70 * <li> The use of <tt>@XmlList</tt> with {@link XmlValue} while 71 * allowed, is redundant since {@link XmlList} maps a 72 * collection type to a simple schema type that derives by 73 * list just as {@link XmlValue} would. </li> 74 * 75 * <li> The use of <tt>@XmlList</tt> with {@link XmlAttribute} while 76 * allowed, is redundant since {@link XmlList} maps a 77 * collection type to a simple schema type that derives by 78 * list just as {@link XmlAttribute} would. </li> 79 * </ul> 80 * 81 * @author <ul><li>Kohsuke Kawaguchi, Sun Microsystems, Inc.</li><li>Sekhar Vajjhala, Sun Microsystems, Inc.</li></ul> 82 * @since JAXB2.0 83 */ 84 @Retention(RUNTIME) @Target({FIELD,METHOD,PARAMETER}) 85 public @interface XmlList { 86 } 87