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.adapters;
027
028 import javax.xml.bind.annotation.XmlAnyElement;
029 import javax.xml.bind.annotation.XmlElementRefs;
030 import javax.xml.bind.annotation.XmlElement;
031 import javax.xml.bind.annotation.XmlSchemaType;
032 import javax.xml.bind.annotation.XmlElementRef;
033 import javax.xml.bind.annotation.XmlAttribute;
034 import javax.xml.bind.annotation.XmlSchema;
035 import javax.xml.bind.annotation.XmlAccessorType;
036 import javax.xml.bind.annotation.XmlSchemaTypes;
037 import java.lang.annotation.Target;
038 import java.lang.annotation.Retention;
039
040 import static java.lang.annotation.RetentionPolicy.RUNTIME;
041 import static java.lang.annotation.ElementType.FIELD;
042 import static java.lang.annotation.ElementType.METHOD;
043 import static java.lang.annotation.ElementType.TYPE;
044 import static java.lang.annotation.ElementType.PARAMETER;
045 import static java.lang.annotation.ElementType.PACKAGE;
046
047 /**
048 * Use an adapter that implements {@link XmlAdapter} for custom marshaling.
049 *
050 * <p> <b> Usage: </b> </p>
051 *
052 * <p> The <tt>@XmlJavaTypeAdapter</tt> annotation can be used with the
053 * following program elements:
054 * <ul>
055 * <li> a JavaBean property </li>
056 * <li> field </li>
057 * <li> parameter </li>
058 * <li> package </li>
059 * <li> from within {@link XmlJavaTypeAdapters} </li>
060 * </ul>
061 *
062 * <p> When <tt>@XmlJavaTypeAdapter</tt> annotation is defined on a
063 * class, it applies to all references to the class.
064 * <p> When <tt>@XmlJavaTypeAdapter</tt> annotation is defined at the
065 * package level it applies to all references from within the package
066 * to <tt>@XmlJavaTypeAdapter.type()</tt>.
067 * <p> When <tt>@XmlJavaTypeAdapter</tt> annotation is defined on the
068 * field, property or parameter, then the annotation applies to the
069 * field, property or the parameter only.
070 * <p> A <tt>@XmlJavaTypeAdapter</tt> annotation on a field, property
071 * or parameter overrides the <tt>@XmlJavaTypeAdapter</tt> annotation
072 * associated with the class being referenced by the field, property
073 * or parameter.
074 * <p> A <tt>@XmlJavaTypeAdapter</tt> annotation on a class overrides
075 * the <tt>@XmlJavaTypeAdapter</tt> annotation specified at the
076 * package level for that class.
077 *
078 * <p>This annotation can be used with the following other annotations:
079 * {@link XmlElement}, {@link XmlAttribute}, {@link XmlElementRef},
080 * {@link XmlElementRefs}, {@link XmlAnyElement}. This can also be
081 * used at the package level with the following annotations:
082 * {@link XmlAccessorType}, {@link XmlSchema}, {@link XmlSchemaType},
083 * {@link XmlSchemaTypes}.
084 *
085 * <p><b> Example: </b> See example in {@link XmlAdapter}
086 *
087 * @author <ul><li>Sekhar Vajjhala, Sun Microsystems Inc.</li> <li> Kohsuke Kawaguchi, Sun Microsystems Inc.</li></ul>
088 * @since JAXB2.0
089 * @see XmlAdapter
090 * @version $Revision: 1.9 $
091 */
092
093 @Retention(RUNTIME)
094 @Target({PACKAGE,FIELD,METHOD,TYPE,PARAMETER})
095 public @interface XmlJavaTypeAdapter {
096 /**
097 * Points to the clsss that converts a value type to a bound type or vice versa.
098 * See {@link XmlAdapter} for more details.
099 */
100 Class<? extends XmlAdapter> value();
101
102 /**
103 * If this annotation is used at the package level, then value of
104 * the type() must be specified.
105 */
106
107 Class type() default DEFAULT.class;
108
109 /**
110 * Used in {@link XmlJavaTypeAdapter#type()} to
111 * signal that the type be inferred from the signature
112 * of the field, property, parameter or the class.
113 */
114
115 static final class DEFAULT {
116 }
117
118 }
|