1 /* 2 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 3 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 */ 5 6 package javax.xml.bind.annotation.adapters; 7 8 import javax.xml.bind.annotation.XmlAnyElement; 9 import javax.xml.bind.annotation.XmlElementRefs; 10 import javax.xml.bind.annotation.XmlElement; 11 import javax.xml.bind.annotation.XmlSchemaType; 12 import javax.xml.bind.annotation.XmlElementRef; 13 import javax.xml.bind.annotation.XmlAttribute; 14 import javax.xml.bind.annotation.XmlSchema; 15 import javax.xml.bind.annotation.XmlAccessorType; 16 import javax.xml.bind.annotation.XmlSchemaTypes; 17 import java.lang.annotation.Target; 18 import java.lang.annotation.Retention; 19 20 import static java.lang.annotation.RetentionPolicy.RUNTIME; 21 import static java.lang.annotation.ElementType.FIELD; 22 import static java.lang.annotation.ElementType.METHOD; 23 import static java.lang.annotation.ElementType.TYPE; 24 import static java.lang.annotation.ElementType.PARAMETER; 25 import static java.lang.annotation.ElementType.PACKAGE; 26 27 28 /** 29 * Use an adapter that implements {@link XmlAdapter} for custom marshaling. 30 * 31 * <p> <b> Usage: </b> </p> 32 * 33 * <p> The <tt>@XmlJavaTypeAdapter</tt> annotation can be used with the 34 * following program elements: 35 * <ul> 36 * <li> a JavaBean property </li> 37 * <li> field </li> 38 * <li> parameter </li> 39 * <li> package </li> 40 * <li> from within {@link XmlJavaTypeAdapters} </li> 41 * </ul> 42 * 43 * <p> When <tt>@XmlJavaTypeAdapter</tt> annotation is defined on a 44 * class, it applies to all references to the class. 45 * <p> When <tt>@XmlJavaTypeAdapter</tt> annotation is defined at the 46 * package level it applies to all references from within the package 47 * to <tt>@XmlJavaTypeAdapter.type()</tt>. 48 * <p> When <tt>@XmlJavaTypeAdapter</tt> annotation is defined on the 49 * field, property or parameter, then the annotation applies to the 50 * field, property or the parameter only. 51 * <p> A <tt>@XmlJavaTypeAdapter</tt> annotation on a field, property 52 * or parameter overrides the <tt>@XmlJavaTypeAdapter</tt> annotation 53 * associated with the class being referenced by the field, property 54 * or parameter. 55 * <p> A <tt>@XmlJavaTypeAdapter</tt> annotation on a class overrides 56 * the <tt>@XmlJavaTypeAdapter</tt> annotation specified at the 57 * package level for that class. 58 * 59 * <p>This annotation can be used with the following other annotations: 60 * {@link XmlElement}, {@link XmlAttribute}, {@link XmlElementRef}, 61 * {@link XmlElementRefs}, {@link XmlAnyElement}. This can also be 62 * used at the package level with the following annotations: 63 * {@link XmlAccessorType}, {@link XmlSchema}, {@link XmlSchemaType}, 64 * {@link XmlSchemaTypes}. 65 * 66 * <p><b> Example: </b> See example in {@link XmlAdapter} 67 * 68 * @author <ul><li>Sekhar Vajjhala, Sun Microsystems Inc.</li> <li> Kohsuke Kawaguchi, Sun Microsystems Inc.</li></ul> 69 * @since JAXB2.0 70 * @see XmlAdapter 71 * @version $Revision: 1.9 $ 72 */ 73 74 @Retention(RUNTIME) @Target({PACKAGE,FIELD,METHOD,TYPE,PARAMETER}) 75 public @interface XmlJavaTypeAdapter { 76 /** 77 * Points to the clsss that converts a value type to a bound type or vice versa. 78 * See {@link XmlAdapter} for more details. 79 */ 80 Class<? extends XmlAdapter> value(); 81 82 /** 83 * If this annotation is used at the package level, then value of 84 * the type() must be specified. 85 */ 86 87 Class type() default DEFAULT.class; 88 89 /** 90 * Used in {@link XmlJavaTypeAdapter#type()} to 91 * signal that the type be inferred from the signature 92 * of the field, property, parameter or the class. 93 */ 94 95 static final class DEFAULT {} 96 97 } 98