Class XMLConversionManager

    • Field Detail

      • defaultXMLTypes

        protected static java.util.HashMap defaultXMLTypes
      • defaultJavaTypes

        protected static java.util.HashMap defaultJavaTypes
      • timeZoneQualified

        protected boolean timeZoneQualified
      • timeZone

        protected java.util.TimeZone timeZone
      • datatypeFactory

        protected javax.xml.datatype.DatatypeFactory datatypeFactory
    • Constructor Detail

      • XMLConversionManager

        public XMLConversionManager()
    • Method Detail

      • getDatatypeFactory

        protected javax.xml.datatype.DatatypeFactory getDatatypeFactory()
        INTERNAL: Return the DatatypeFactory instance.
        Returns:
      • getTimeZone

        public java.util.TimeZone getTimeZone()
        Return the specified TimeZone used for all String to date object conversions.
        Specified by:
        getTimeZone in interface TimeZoneHolder
      • setTimeZone

        public void setTimeZone​(java.util.TimeZone timeZone)
        The specified TimeZone will be used for all String to date object conversions. By default the TimeZone from the JVM is used.
      • isTimeZoneQualified

        public boolean isTimeZoneQualified()
      • setTimeZoneQualified

        public void setTimeZoneQualified​(boolean timeZoneQualified)
        Specify if Specify if when date objects are converted to Strings in the XML Schema time or dateTime format
      • convertObject

        public java.lang.Object convertObject​(java.lang.Object sourceObject,
                                              java.lang.Class javaClass)
                                       throws ConversionException
        Convert the given object to the appropriate type by invoking the appropriate ConversionManager method.
        Overrides:
        convertObject in class ConversionManager
        Parameters:
        sourceObject - - will always be a string if read from XML
        javaClass - - the class that the object must be converted to
        Returns:
        - the newly converted object
        Throws:
        ConversionException
      • convertObject

        public java.lang.Object convertObject​(java.lang.Object sourceObject,
                                              java.lang.Class javaClass,
                                              javax.xml.namespace.QName schemaTypeQName)
                                       throws ConversionException
        Convert the given object to the appropriate type by invoking the appropriate ConversionManager method.
        Specified by:
        convertObject in interface ConversionManager
        Parameters:
        sourceObject - - will always be a string if read from XML
        javaClass - - the class that the object must be converted to
        schemaTypeQName - - the XML schema that the object is being converted from
        Returns:
        - the newly converted object
        Throws:
        ConversionException
      • convertObjectToXMLGregorianCalendar

        protected javax.xml.datatype.XMLGregorianCalendar convertObjectToXMLGregorianCalendar​(java.lang.Object sourceObject,
                                                                                              javax.xml.namespace.QName schemaTypeQName)
                                                                                       throws ConversionException
        Build a valid instance of XMLGregorianCalendar from the provided sourceObject.
        Parameters:
        sourceObject -
        schemaTypeQName -
        Throws:
        ConversionException
      • convertObjectToXMLGregorianCalendar

        protected javax.xml.datatype.XMLGregorianCalendar convertObjectToXMLGregorianCalendar​(java.lang.Object sourceObject)
                                                                                       throws ConversionException
        Build a valid instance of XMLGregorianCalendar from the provided sourceObject.
        Parameters:
        sourceObject -
        Throws:
        ConversionException
      • convertObjectToDuration

        protected javax.xml.datatype.Duration convertObjectToDuration​(java.lang.Object sourceObject)
                                                               throws ConversionException
        Build a valid instance of Duration from the provided sourceObject.
        Parameters:
        sourceObject -
        Throws:
        ConversionException
      • convertObjectToChar

        protected java.lang.Character convertObjectToChar​(java.lang.Object sourceObject,
                                                          javax.xml.namespace.QName schemaTypeQName)
                                                   throws ConversionException
        Build a valid instance of Character from the provided sourceObject.
        Parameters:
        sourceObject -
        Throws:
        ConversionException
      • convertObjectToURI

        protected java.net.URI convertObjectToURI​(java.lang.Object sourceObject)
                                           throws ConversionException
        Convert a String to a URI.
        Parameters:
        sourceObject -
        Returns:
        Throws:
        ConversionException
      • convertObjectToQName

        protected javax.xml.namespace.QName convertObjectToQName​(java.lang.Object sourceObject)
                                                          throws ConversionException
        INTERNAL: Converts given object to a QName object
        Throws:
        ConversionException
      • convertObjectToString

        protected java.lang.String convertObjectToString​(java.lang.Object sourceObject,
                                                         javax.xml.namespace.QName schemaTypeQName)
                                                  throws ConversionException
        Throws:
        ConversionException
      • convertObjectToNumber

        protected java.math.BigDecimal convertObjectToNumber​(java.lang.Object sourceObject)
                                                      throws ConversionException
        INTERNAL: Build a valid BigDecimal instance from a String or another Number instance. BigDecimal is the most general type so is must be returned when an object is converted to a number.
        Overrides:
        convertObjectToNumber in class ConversionManager
        Throws:
        ConversionException
      • convertObjectToBoolean

        protected java.lang.Boolean convertObjectToBoolean​(java.lang.Object sourceObject)
        Description copied from class: ConversionManager
        Build a valid instance of Boolean from the source object. 't', 'T', "true", "TRUE", 1,'1' -> Boolean(true) 'f', 'F', "false", "FALSE", 0 ,'0' -> Boolean(false)
        Overrides:
        convertObjectToBoolean in class ConversionManager
      • convertStringToXMLGregorianCalendar

        public javax.xml.datatype.XMLGregorianCalendar convertStringToXMLGregorianCalendar​(java.lang.String sourceString,
                                                                                           javax.xml.namespace.QName schemaTypeQName)
      • convertStringToXMLGregorianCalendar

        public javax.xml.datatype.XMLGregorianCalendar convertStringToXMLGregorianCalendar​(java.lang.String sourceString)
        Return an XMLGregorianCalander created with a given date string
        Parameters:
        dateString -
        Returns:
      • convertStringToDuration

        public javax.xml.datatype.Duration convertStringToDuration​(java.lang.String sourceString)
        Return a Duration created with a given date string.
        Parameters:
        dateString -
        Returns:
      • convertStringToCalendar

        public java.util.Calendar convertStringToCalendar​(java.lang.String sourceString,
                                                          javax.xml.namespace.QName schemaTypeQName)
      • convertObjectToSQLDate

        protected java.sql.Date convertObjectToSQLDate​(java.lang.Object sourceObject,
                                                       javax.xml.namespace.QName schemaTypeQName)
      • convertObjectToSQLTime

        protected java.sql.Time convertObjectToSQLTime​(java.lang.Object sourceObject,
                                                       javax.xml.namespace.QName schemaTypeQName)
      • convertStringToTimestamp

        protected java.sql.Timestamp convertStringToTimestamp​(java.lang.String sourceObject)
      • convertObjectToTimestamp

        protected java.sql.Timestamp convertObjectToTimestamp​(java.lang.Object sourceObject,
                                                              javax.xml.namespace.QName schemaTypeQName)
      • convertStringToTimestamp

        public java.sql.Timestamp convertStringToTimestamp​(java.lang.String sourceString,
                                                           javax.xml.namespace.QName schemaType)
      • stringFromCalendar

        public java.lang.String stringFromCalendar​(java.util.Calendar sourceCalendar,
                                                   javax.xml.namespace.QName schemaTypeQName)
      • convertStringToDate

        public java.util.Date convertStringToDate​(java.lang.String sourceString,
                                                  javax.xml.namespace.QName schemaType)
      • stringFromDate

        public java.lang.String stringFromDate​(java.util.Date sourceDate,
                                               javax.xml.namespace.QName schemaType)
        This method returns a string representing a given java.util.Date based on a given schema type QName. BC dates (sourceDate.getTime() < YEAR_ONE_AD_TIME) are handled as follows: '2007 BC' --> '-2006 AD'.
        Parameters:
        sourceDate -
        schemaType -
        Returns:
      • convertSchemaBase64ToByteObjectArray

        protected java.lang.Byte[] convertSchemaBase64ToByteObjectArray​(java.lang.Object sourceObject)
                                                                 throws ConversionException
        Throws:
        ConversionException
      • buildBase64StringFromObjectBytes

        public java.lang.String buildBase64StringFromObjectBytes​(java.lang.Byte[] bytes)
      • buildHexStringFromObjectBytes

        protected java.lang.String buildHexStringFromObjectBytes​(java.lang.Byte[] bytes)
      • convertStringToFile

        protected java.io.File convertStringToFile​(java.lang.String path)
      • convertStringToList

        public java.lang.Object convertStringToList​(java.lang.Object sourceObject,
                                                    java.lang.Class elementType,
                                                    ContainerPolicy containerPolicy,
                                                    javax.xml.namespace.QName schemaType)
                                             throws ConversionException
        Convert the given sourceObject (String) to the appropriate collection type specified by the containerPolicy, using the elementType to properly convert each element of the list.
        Parameters:
        sourceObject - - will always be a string if read from XML
        elementType - - the type of the elements contained in the list
        Returns:
        - the newly converted object
        Throws:
        ConversionException
      • convertListToString

        public java.lang.String convertListToString​(java.lang.Object sourceObject,
                                                    javax.xml.namespace.QName schemaType)
                                             throws ConversionException
        Throws:
        ConversionException
      • convertArrayToString

        public java.lang.String convertArrayToString​(java.lang.Object[] sourceObject,
                                                     javax.xml.namespace.QName schemaType)
                                              throws ConversionException
        Throws:
        ConversionException
      • getDefaultXMLTypes

        public static java.util.HashMap getDefaultXMLTypes()
      • getDefaultJavaTypes

        public static java.util.HashMap getDefaultJavaTypes()
      • normalizeStringValue

        public java.lang.String normalizeStringValue​(java.lang.String value)
        Replaces any CR, Tab or LF characters in the string with a single ' ' character.
        Specified by:
        normalizeStringValue in interface ConversionManager
      • collapseStringValue

        public java.lang.String collapseStringValue​(java.lang.String value)
        Removes all leading and trailing whitespaces, and replaces any sequences of whitespaces that occur in the string with a single ' ' character.
        Specified by:
        collapseStringValue in interface ConversionManager
      • javaType

        public java.lang.Class<?> javaType​(javax.xml.namespace.QName schemaType)
        Specified by:
        javaType in interface ConversionManager
        Parameters:
        schemaType - The type you want to find a corresponding Java class for.
        Returns:
        the Java class for the XML schema type.
        Since:
        EclipseLink 2.6.0
      • schemaType

        public javax.xml.namespace.QName schemaType​(java.lang.Class<?> javaType)
        Specified by:
        schemaType in interface ConversionManager
        Parameters:
        javaType - The type you want to find a corresponding schema type for.
        Returns:
        the schema type for the Java class.
        Since:
        EclipseLink 2.6.0