325N/A/*
325N/A * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
325N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
325N/A *
325N/A * This code is free software; you can redistribute it and/or modify it
325N/A * under the terms of the GNU General Public License version 2 only, as
325N/A * published by the Free Software Foundation. Oracle designates this
325N/A * particular file as subject to the "Classpath" exception as provided
325N/A * by Oracle in the LICENSE file that accompanied this code.
325N/A *
325N/A * This code is distributed in the hope that it will be useful, but WITHOUT
325N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
325N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
325N/A * version 2 for more details (a copy is included in the LICENSE file that
325N/A * accompanied this code).
325N/A *
325N/A * You should have received a copy of the GNU General Public License version
325N/A * 2 along with this work; if not, write to the Free Software Foundation,
325N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
325N/A *
325N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
325N/A * or visit www.oracle.com if you need additional information or have any
325N/A * questions.
325N/A */
325N/A
325N/Apackage javax.xml.bind.annotation;
325N/A
325N/Aimport java.lang.annotation.Retention;
325N/Aimport java.lang.annotation.Target;
325N/Aimport static java.lang.annotation.RetentionPolicy.RUNTIME;
325N/Aimport static java.lang.annotation.ElementType.FIELD;
325N/A
325N/A/**
325N/A * Maps an enum constant in {@link Enum} type to XML representation.
325N/A *
325N/A * <p> <b>Usage</b> </p>
325N/A *
325N/A * <p> The <tt>@XmlEnumValue</tt> annotation can be used with the
325N/A * following program elements:
325N/A * <ul>
325N/A * <li>enum constant</li>
325N/A * </ul>
325N/A *
325N/A * <p>See "Package Specification" in javax.xml.bind.package javadoc for
325N/A * additional common information.</p>
325N/A *
325N/A * <p>This annotation, together with {@link XmlEnum} provides a
325N/A * mapping of enum type to XML representation.
325N/A *
325N/A * <p>An enum type is mapped to a schema simple type with enumeration
325N/A * facets. The schema type is derived from the Java type specified in
325N/A * <tt>@XmlEnum.value()</tt>. Each enum constant <tt>@XmlEnumValue</tt>
325N/A * must have a valid lexical representation for the type
325N/A * <tt>@XmlEnum.value()</tt>
325N/A *
325N/A * <p> In the absence of this annotation, {@link Enum#name()} is used
325N/A * as the XML representation.
325N/A *
325N/A * <p> <b>Example 1: </b>Map enum constant name -> enumeration facet</p>
325N/A * <pre>
325N/A * //Example: Code fragment
325N/A * &#64;XmlEnum(String.class)
325N/A * public enum Card { CLUBS, DIAMONDS, HEARTS, SPADES }
325N/A *
325N/A * &lt;!-- Example: XML Schema fragment -->
325N/A * &lt;xs:simpleType name="Card">
325N/A * &lt;xs:restriction base="xs:string"/>
325N/A * &lt;xs:enumeration value="CLUBS"/>
325N/A * &lt;xs:enumeration value="DIAMONDS"/>
325N/A * &lt;xs:enumeration value="HEARTS"/>
325N/A * &lt;xs:enumeration value="SPADES"/>
325N/A * &lt;/xs:simpleType>
325N/A * </pre>
325N/A *
325N/A * <p><b>Example 2: </b>Map enum constant name(value) -> enumeration facet </p>
325N/A * <pre>
325N/A * //Example: code fragment
325N/A * &#64;XmlType
325N/A * &#64;XmlEnum(Integer.class)
325N/A * public enum Coin {
325N/A * &#64;XmlEnumValue("1") PENNY(1),
325N/A * &#64;XmlEnumValue("5") NICKEL(5),
325N/A * &#64;XmlEnumValue("10") DIME(10),
325N/A * &#64;XmlEnumValue("25") QUARTER(25) }
325N/A *
325N/A * &lt;!-- Example: XML Schema fragment -->
325N/A * &lt;xs:simpleType name="Coin">
325N/A * &lt;xs:restriction base="xs:int">
325N/A * &lt;xs:enumeration value="1"/>
325N/A * &lt;xs:enumeration value="5"/>
325N/A * &lt;xs:enumeration value="10"/>
325N/A * &lt;xs:enumeration value="25"/>
325N/A * &lt;/xs:restriction>
325N/A * &lt;/xs:simpleType>
325N/A * </pre>
325N/A *
325N/A * <p><b>Example 3: </b>Map enum constant name -> enumeration facet </p>
325N/A *
325N/A * <pre>
325N/A * //Code fragment
325N/A * &#64;XmlType
325N/A * &#64;XmlEnum(Integer.class)
325N/A * public enum Code {
325N/A * &#64;XmlEnumValue("1") ONE,
325N/A * &#64;XmlEnumValue("2") TWO;
325N/A * }
325N/A *
325N/A * &lt;!-- Example: XML Schema fragment -->
325N/A * &lt;xs:simpleType name="Code">
325N/A * &lt;xs:restriction base="xs:int">
325N/A * &lt;xs:enumeration value="1"/>
325N/A * &lt;xs:enumeration value="2"/>
325N/A * &lt;/xs:restriction>
325N/A * &lt;/xs:simpleType>
325N/A * </pre>
325N/A *
325N/A * @since JAXB 2.0
325N/A */
325N/A@Retention(RUNTIME)
325N/A@Target({FIELD})
325N/Apublic @interface XmlEnumValue {
325N/A String value();
325N/A}