Class XMLJavaTypeConverter

  • All Implemented Interfaces:
    java.io.Serializable, org.eclipse.persistence.core.mappings.converters.CoreConverter<org.eclipse.persistence.mappings.DatabaseMapping,​org.eclipse.persistence.sessions.Session>, org.eclipse.persistence.mappings.converters.Converter, org.eclipse.persistence.oxm.mappings.converters.XMLConverter

    public class XMLJavaTypeConverter
    extends org.eclipse.persistence.oxm.mappings.converters.XMLConverterAdapter
    Converter that wraps an XmlAdapter.
    See Also:
    XmlAdapter, Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.Class<?> boundType  
      protected org.eclipse.persistence.mappings.DatabaseMapping mapping  
      protected org.eclipse.persistence.core.mappings.converters.CoreConverter<org.eclipse.persistence.mappings.DatabaseMapping,​org.eclipse.persistence.sessions.Session> nestedConverter  
      protected javax.xml.namespace.QName schemaType  
      protected java.lang.Class<?> valueType  
      protected javax.xml.bind.annotation.adapters.XmlAdapter<?,​?> xmlAdapter  
      protected java.lang.Class<? extends javax.xml.bind.annotation.adapters.XmlAdapter<?,​?>> xmlAdapterClass  
      protected java.lang.String xmlAdapterClassName  
    • Constructor Summary

      Constructors 
      Constructor Description
      XMLJavaTypeConverter()
      The default constructor.
      XMLJavaTypeConverter​(java.lang.Class<?> xmlAdapterClass)
      This constructor takes the XmlAdapter class to be used with this converter.
      XMLJavaTypeConverter​(java.lang.Class<?> xmlAdapterClass, javax.xml.namespace.QName schemaType)
      This constructor takes the XmlAdapter class to be used with this converter, as well as a schema type to be used during the conversion operation.
      XMLJavaTypeConverter​(java.lang.String xmlAdapterClassName)
      This constructor takes an adapter class name.
      XMLJavaTypeConverter​(java.lang.String xmlAdapterClassName, javax.xml.namespace.QName schemaType)
      This constructor takes the XmlAdapter class name to be used with this converter (loaded during initialization), as well as a schema type to be used during the conversion operation.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object convertDataValueToObjectValue​(java.lang.Object dataValue, org.eclipse.persistence.sessions.Session session, org.eclipse.persistence.oxm.XMLUnmarshaller unmarshaller)
      Wraps the XmlAdapter unmarshal method.
      java.lang.Object convertObjectValueToDataValue​(java.lang.Object objectValue, org.eclipse.persistence.sessions.Session session, org.eclipse.persistence.oxm.XMLMarshaller marshaller)
      Wraps the XmlAdapter marshal method.
      org.eclipse.persistence.core.mappings.converters.CoreConverter<org.eclipse.persistence.mappings.DatabaseMapping,​org.eclipse.persistence.sessions.Session> getNestedConverter()
      Get the nested converter to that is used in conjunction with the adapter.
      javax.xml.namespace.QName getSchemaType()
      Get the schema type to be used during conversion.
      java.lang.Class<? extends javax.xml.bind.annotation.adapters.XmlAdapter<?,​?>> getXmlAdapterClass()
      Return the XmlAdapter class for this converter.
      java.lang.String getXmlAdapterClassName()
      Return the XmlAdapter class name for this converter.
      void initialize​(org.eclipse.persistence.mappings.DatabaseMapping mapping, org.eclipse.persistence.sessions.Session session)
      Figure out the BoundType and ValueType for the XmlAdapter class, then either create an instance of the XmlAdapter, or if an instance is set on the marshaller, use it.
      boolean isMutable()
      Satisfy the interface.
      void setNestedConverter​(org.eclipse.persistence.core.mappings.converters.CoreConverter<org.eclipse.persistence.mappings.DatabaseMapping,​org.eclipse.persistence.sessions.Session> nestedConverter)
      Set a nested converter to be used in conjunction with the adapter.
      void setSchemaType​(javax.xml.namespace.QName qname)
      Set the schema type to be used during conversion - if one is required.
      void setXmlAdapterClass​(java.lang.Class<? extends javax.xml.bind.annotation.adapters.XmlAdapter<?,​?>> xmlAdapterClass)
      Set the XmlAdapter class to be used with this converter.
      void setXmlAdapterClassName​(java.lang.String xmlAdapterClassName)
      Set the XmlAdapter class to be used with this converter.
      • Methods inherited from class org.eclipse.persistence.oxm.mappings.converters.XMLConverterAdapter

        convertDataValueToObjectValue, convertObjectValueToDataValue
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • boundType

        protected java.lang.Class<?> boundType
      • valueType

        protected java.lang.Class<?> valueType
      • xmlAdapterClass

        protected java.lang.Class<? extends javax.xml.bind.annotation.adapters.XmlAdapter<?,​?>> xmlAdapterClass
      • xmlAdapterClassName

        protected java.lang.String xmlAdapterClassName
      • xmlAdapter

        protected javax.xml.bind.annotation.adapters.XmlAdapter<?,​?> xmlAdapter
      • schemaType

        protected javax.xml.namespace.QName schemaType
      • mapping

        protected org.eclipse.persistence.mappings.DatabaseMapping mapping
      • nestedConverter

        protected org.eclipse.persistence.core.mappings.converters.CoreConverter<org.eclipse.persistence.mappings.DatabaseMapping,​org.eclipse.persistence.sessions.Session> nestedConverter
    • Constructor Detail

      • XMLJavaTypeConverter

        public XMLJavaTypeConverter()
        The default constructor. This constructor should be used in conjunction with the setXmlAdapterClass method or setXmlAdapterClassName method.
      • XMLJavaTypeConverter

        public XMLJavaTypeConverter​(java.lang.Class<?> xmlAdapterClass)
        This constructor takes the XmlAdapter class to be used with this converter.
        Parameters:
        xmlAdapterClass -
      • XMLJavaTypeConverter

        public XMLJavaTypeConverter​(java.lang.String xmlAdapterClassName)
        This constructor takes an adapter class name. The adapter class will be loaded during initialization.
        Parameters:
        xmlAdapterClassName -
      • XMLJavaTypeConverter

        public XMLJavaTypeConverter​(java.lang.Class<?> xmlAdapterClass,
                                    javax.xml.namespace.QName schemaType)
        This constructor takes the XmlAdapter class to be used with this converter, as well as a schema type to be used during the conversion operation. During unmarshal, the value type will be converted to the schema type, then from that type to the bound type. The opposite will occur during marshal.
        Parameters:
        xmlAdapterClass -
        schemaType -
      • XMLJavaTypeConverter

        public XMLJavaTypeConverter​(java.lang.String xmlAdapterClassName,
                                    javax.xml.namespace.QName schemaType)
        This constructor takes the XmlAdapter class name to be used with this converter (loaded during initialization), as well as a schema type to be used during the conversion operation. During unmarshal, the value type will be converted to the schema type, then from that type to the bound type. The opposite will occur during marshal.
        Parameters:
        xmlAdapterClassName -
        schemaType -
    • Method Detail

      • convertDataValueToObjectValue

        public java.lang.Object convertDataValueToObjectValue​(java.lang.Object dataValue,
                                                              org.eclipse.persistence.sessions.Session session,
                                                              org.eclipse.persistence.oxm.XMLUnmarshaller unmarshaller)
        Wraps the XmlAdapter unmarshal method.
      • convertObjectValueToDataValue

        public java.lang.Object convertObjectValueToDataValue​(java.lang.Object objectValue,
                                                              org.eclipse.persistence.sessions.Session session,
                                                              org.eclipse.persistence.oxm.XMLMarshaller marshaller)
        Wraps the XmlAdapter marshal method.
      • getSchemaType

        public javax.xml.namespace.QName getSchemaType()
        Get the schema type to be used during conversion.
      • getXmlAdapterClass

        public java.lang.Class<? extends javax.xml.bind.annotation.adapters.XmlAdapter<?,​?>> getXmlAdapterClass()
        Return the XmlAdapter class for this converter.
        Returns:
        xmlAdapterClass
      • getXmlAdapterClassName

        public java.lang.String getXmlAdapterClassName()
        Return the XmlAdapter class name for this converter. If null, the name will be set to "".
        Returns:
        xmlAdapterClassName
      • initialize

        public void initialize​(org.eclipse.persistence.mappings.DatabaseMapping mapping,
                               org.eclipse.persistence.sessions.Session session)
        Figure out the BoundType and ValueType for the XmlAdapter class, then either create an instance of the XmlAdapter, or if an instance is set on the marshaller, use it.
        Parameters:
        mapping -
        session -
      • isMutable

        public boolean isMutable()
        Satisfy the interface.
      • setSchemaType

        public void setSchemaType​(javax.xml.namespace.QName qname)
        Set the schema type to be used during conversion - if one is required.
      • setXmlAdapterClass

        public void setXmlAdapterClass​(java.lang.Class<? extends javax.xml.bind.annotation.adapters.XmlAdapter<?,​?>> xmlAdapterClass)
        Set the XmlAdapter class to be used with this converter.
        Parameters:
        xmlAdapterClass -
      • setXmlAdapterClassName

        public void setXmlAdapterClassName​(java.lang.String xmlAdapterClassName)
        Set the XmlAdapter class to be used with this converter.
        Parameters:
        xmlAdapterClassName -
      • getNestedConverter

        public org.eclipse.persistence.core.mappings.converters.CoreConverter<org.eclipse.persistence.mappings.DatabaseMapping,​org.eclipse.persistence.sessions.Session> getNestedConverter()
        Get the nested converter to that is used in conjunction with the adapter.
      • setNestedConverter

        public void setNestedConverter​(org.eclipse.persistence.core.mappings.converters.CoreConverter<org.eclipse.persistence.mappings.DatabaseMapping,​org.eclipse.persistence.sessions.Session> nestedConverter)
        Set a nested converter to be used in conjunction with the adapter. On marshal, the nested converter is invoked after the adapter. On umarshal it is invoked before. Primarily used to support enumerations with adapters.