001 /*
002 * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation. Sun designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Sun in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022 * CA 95054 USA or visit www.sun.com if you need additional information or
023 * have any questions.
024 */
025
026 package javax.xml.bind.annotation;
027
028 import java.lang.annotation.Retention;
029 import java.lang.annotation.Target;
030 import static java.lang.annotation.RetentionPolicy.RUNTIME;
031 import static java.lang.annotation.ElementType.FIELD;
032 import static java.lang.annotation.ElementType.METHOD;
033 import static java.lang.annotation.ElementType.PARAMETER;
034
035 /**
036 * Used to map a property to a list simple type.
037 *
038 * <p><b>Usage</b> </p>
039 * <p>
040 * The <tt>@XmlList</tt> annotation can be used with the
041 * following program elements:
042 * <ul>
043 * <li> JavaBean property </li>
044 * <li> field </li>
045 * </ul>
046 *
047 * <p>
048 * When a collection property is annotated just with @XmlElement,
049 * each item in the collection will be wrapped by an element.
050 * For example,
051 *
052 * <pre>
053 * @XmlRootElement
054 * class Foo {
055 * @XmlElement
056 * List<String> data;
057 * }
058 * </pre>
059 *
060 * would produce XML like this:
061 *
062 * <pre><xmp>
063 * <foo>
064 * <data>abc</data>
065 * <data>def</data>
066 * </foo>
067 * </xmp></pre>
068 *
069 * @XmlList annotation, on the other hand, allows multiple values to be
070 * represented as whitespace-separated tokens in a single element. For example,
071 *
072 * <pre>
073 * @XmlRootElement
074 * class Foo {
075 * @XmlElement
076 * @XmlList
077 * List<String> data;
078 * }
079 * </pre>
080 *
081 * the above code will produce XML like this:
082 *
083 * <pre><xmp>
084 * <foo>
085 * <data>abc def</data>
086 * </foo>
087 * </xmp></pre>
088 *
089 * <p>This annotation can be used with the following annotations:
090 * {@link XmlElement},
091 * {@link XmlAttribute},
092 * {@link XmlValue},
093 * {@link XmlIDREF}.
094 * <ul>
095 * <li> The use of <tt>@XmlList</tt> with {@link XmlValue} while
096 * allowed, is redundant since {@link XmlList} maps a
097 * collection type to a simple schema type that derives by
098 * list just as {@link XmlValue} would. </li>
099 *
100 * <li> The use of <tt>@XmlList</tt> with {@link XmlAttribute} while
101 * allowed, is redundant since {@link XmlList} maps a
102 * collection type to a simple schema type that derives by
103 * list just as {@link XmlAttribute} would. </li>
104 * </ul>
105 *
106 * @author <ul><li>Kohsuke Kawaguchi, Sun Microsystems, Inc.</li><li>Sekhar Vajjhala, Sun Microsystems, Inc.</li></ul>
107 * @since JAXB2.0
108 */
109 @Retention(RUNTIME)
110 @Target({FIELD,METHOD,PARAMETER})
111 public @interface XmlList {
112 }
|