Home » xml-commons-external-1.4.01-src » javax » xml » bind » annotation » adapters » [javadoc | source]

    1   /*
    2    * Copyright 2005-2006 Sun Microsystems, Inc.  All Rights Reserved.
    3    * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    4    *
    5    * This code is free software; you can redistribute it and/or modify it
    6    * under the terms of the GNU General Public License version 2 only, as
    7    * published by the Free Software Foundation.  Sun designates this
    8    * particular file as subject to the "Classpath" exception as provided
    9    * by Sun in the LICENSE file that accompanied this code.
   10    *
   11    * This code is distributed in the hope that it will be useful, but WITHOUT
   12    * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   13    * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   14    * version 2 for more details (a copy is included in the LICENSE file that
   15    * accompanied this code).
   16    *
   17    * You should have received a copy of the GNU General Public License version
   18    * 2 along with this work; if not, write to the Free Software Foundation,
   19    * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   20    *
   21    * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   22    * CA 95054 USA or visit www.sun.com if you need additional information or
   23    * have any questions.
   24    */
   25   
   26   package javax.xml.bind.annotation.adapters;
   27   
   28   import javax.xml.bind.annotation.XmlAnyElement;
   29   import javax.xml.bind.annotation.XmlElementRefs;
   30   import javax.xml.bind.annotation.XmlElement;
   31   import javax.xml.bind.annotation.XmlSchemaType;
   32   import javax.xml.bind.annotation.XmlElementRef;
   33   import javax.xml.bind.annotation.XmlAttribute;
   34   import javax.xml.bind.annotation.XmlSchema;
   35   import javax.xml.bind.annotation.XmlAccessorType;
   36   import javax.xml.bind.annotation.XmlSchemaTypes;
   37   import java.lang.annotation.Target;
   38   import java.lang.annotation.Retention;
   39   
   40   import static java.lang.annotation.RetentionPolicy.RUNTIME;
   41   import static java.lang.annotation.ElementType.FIELD;
   42   import static java.lang.annotation.ElementType.METHOD;
   43   import static java.lang.annotation.ElementType.TYPE;
   44   import static java.lang.annotation.ElementType.PARAMETER;
   45   import static java.lang.annotation.ElementType.PACKAGE;
   46   
   47   
   48   /**
   49    * Use an adapter that implements {@link XmlAdapter} for custom marshaling.
   50    *
   51    * <p> <b> Usage: </b> </p>
   52    *
   53    * <p> The <tt>@XmlJavaTypeAdapter</tt> annotation can be used with the
   54    * following program elements:
   55    * <ul>
   56    *   <li> a JavaBean property </li>
   57    *   <li> field </li>
   58    *   <li> parameter </li>
   59    *   <li> package </li>
   60    *   <li> from within {@link XmlJavaTypeAdapters} </li>
   61    * </ul>
   62    *
   63    * <p> When <tt>@XmlJavaTypeAdapter</tt> annotation is defined on a
   64    * class, it applies to all references to the class.
   65    * <p> When <tt>@XmlJavaTypeAdapter</tt> annotation is defined at the
   66    * package level it applies to all references from within the package
   67    * to <tt>@XmlJavaTypeAdapter.type()</tt>.
   68    * <p> When <tt>@XmlJavaTypeAdapter</tt> annotation is defined on the
   69    * field, property or parameter, then the annotation applies to the
   70    * field, property or the parameter only.
   71    * <p> A <tt>@XmlJavaTypeAdapter</tt> annotation on a field, property
   72    * or parameter overrides the <tt>@XmlJavaTypeAdapter</tt> annotation
   73    * associated with the class being referenced by the field, property
   74    * or parameter.
   75    * <p> A <tt>@XmlJavaTypeAdapter</tt> annotation on a class overrides
   76    * the <tt>@XmlJavaTypeAdapter</tt> annotation specified at the
   77    * package level for that class.
   78    *
   79    * <p>This annotation can be used with the following other annotations:
   80    * {@link XmlElement}, {@link XmlAttribute}, {@link XmlElementRef},
   81    * {@link XmlElementRefs}, {@link XmlAnyElement}. This can also be
   82    * used at the package level with the following annotations:
   83    * {@link XmlAccessorType}, {@link XmlSchema}, {@link XmlSchemaType},
   84    * {@link XmlSchemaTypes}.
   85    *
   86    * <p><b> Example: </b> See example in {@link XmlAdapter}
   87    *
   88    * @author <ul><li>Sekhar Vajjhala, Sun Microsystems Inc.</li> <li> Kohsuke Kawaguchi, Sun Microsystems Inc.</li></ul>
   89    * @since JAXB2.0
   90    * @see XmlAdapter
   91    * @version $Revision: 1.10 $
   92    */
   93   
   94   @Retention(RUNTIME) @Target({PACKAGE,FIELD,METHOD,TYPE,PARAMETER})
   95   public @interface XmlJavaTypeAdapter {
   96       /**
   97        * Points to the clsss that converts a value type to a bound type or vice versa.
   98        * See {@link XmlAdapter} for more details.
   99        */
  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   }

Home » xml-commons-external-1.4.01-src » javax » xml » bind » annotation » adapters » [javadoc | source]