< prev index next >

src/java.xml.bind/share/classes/com/sun/xml/internal/bind/v2/model/core/Adapter.java

Print this page




  29 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
  30 
  31 import com.sun.xml.internal.bind.v2.model.annotation.AnnotationReader;
  32 import com.sun.xml.internal.bind.v2.model.nav.Navigator;
  33 
  34 /**
  35  * {@link Adapter} that wraps {@link XmlJavaTypeAdapter}.
  36  *
  37  * @author Kohsuke Kawaguchi
  38  */
  39 public class Adapter<TypeT,ClassDeclT> {
  40     /**
  41      * The adapter class. Always non-null.
  42      *
  43      * A class that derives from {@link javax.xml.bind.annotation.adapters.XmlAdapter}.
  44      */
  45     public final ClassDeclT adapterType;
  46 
  47     /**
  48      * The type that the JAXB can handle natively.
  49      * The <tt>Default</tt> parameter of <tt>XmlAdapter&lt;Default,Custom></tt>.
  50      *
  51      * Always non-null.
  52      */
  53     public final TypeT defaultType;
  54 
  55     /**
  56      * The type that is stored in memory.
  57      * The <tt>Custom</tt> parameter of <tt>XmlAdapter&lt;Default,Custom></tt>.
  58      */
  59     public final TypeT customType;
  60 
  61 
  62 
  63     public Adapter(
  64         XmlJavaTypeAdapter spec,
  65         AnnotationReader<TypeT,ClassDeclT,?,?> reader,
  66         Navigator<TypeT,ClassDeclT,?,?> nav) {
  67 
  68         this( nav.asDecl(reader.getClassValue(spec,"value")), nav );
  69     }
  70 
  71     public Adapter(ClassDeclT adapterType,Navigator<TypeT,ClassDeclT,?,?> nav) {
  72         this.adapterType = adapterType;
  73         TypeT baseClass = nav.getBaseClass(nav.use(adapterType), nav.asDecl(XmlAdapter.class));
  74 
  75         // because the parameterization of XmlJavaTypeAdapter requires that the class derives from XmlAdapter.
  76         assert baseClass!=null;
  77 


  29 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
  30 
  31 import com.sun.xml.internal.bind.v2.model.annotation.AnnotationReader;
  32 import com.sun.xml.internal.bind.v2.model.nav.Navigator;
  33 
  34 /**
  35  * {@link Adapter} that wraps {@link XmlJavaTypeAdapter}.
  36  *
  37  * @author Kohsuke Kawaguchi
  38  */
  39 public class Adapter<TypeT,ClassDeclT> {
  40     /**
  41      * The adapter class. Always non-null.
  42      *
  43      * A class that derives from {@link javax.xml.bind.annotation.adapters.XmlAdapter}.
  44      */
  45     public final ClassDeclT adapterType;
  46 
  47     /**
  48      * The type that the JAXB can handle natively.
  49      * The {@code Default} parameter of {@code XmlAdapter<Default,Custom>}.
  50      *
  51      * Always non-null.
  52      */
  53     public final TypeT defaultType;
  54 
  55     /**
  56      * The type that is stored in memory.
  57      * The {@code Custom} parameter of {@code XmlAdapter<Default,Custom>}.
  58      */
  59     public final TypeT customType;
  60 
  61 
  62 
  63     public Adapter(
  64         XmlJavaTypeAdapter spec,
  65         AnnotationReader<TypeT,ClassDeclT,?,?> reader,
  66         Navigator<TypeT,ClassDeclT,?,?> nav) {
  67 
  68         this( nav.asDecl(reader.getClassValue(spec,"value")), nav );
  69     }
  70 
  71     public Adapter(ClassDeclT adapterType,Navigator<TypeT,ClassDeclT,?,?> nav) {
  72         this.adapterType = adapterType;
  73         TypeT baseClass = nav.getBaseClass(nav.use(adapterType), nav.asDecl(XmlAdapter.class));
  74 
  75         // because the parameterization of XmlJavaTypeAdapter requires that the class derives from XmlAdapter.
  76         assert baseClass!=null;
  77 
< prev index next >