Class ConversionManager

    • Field Detail

      • defaultNullValues

        protected Map defaultNullValues
      • shouldUseClassLoaderFromCurrentThread

        protected boolean shouldUseClassLoaderFromCurrentThread
        This flag is here if the Conversion Manager should use the class loader on the thread when loading classes.
      • dataTypesConvertedFromAClass

        protected Hashtable dataTypesConvertedFromAClass
        Store the list of Classes that can be converted to from the key.
      • dataTypesConvertedToAClass

        protected Hashtable dataTypesConvertedToAClass
        Store the list of Classes that can be converted from to the key.
    • Constructor Detail

      • ConversionManager

        public ConversionManager()
    • Method Detail

      • convertObject

        public Object convertObject​(Object sourceObject,
                                    Class javaClass)
                             throws ConversionException
        Convert the object to the appropriate type by invoking the appropriate ConversionManager method
        Specified by:
        convertObject in class CoreConversionManager
        Parameters:
        sourceObject - the object that must be converted
        javaClass - the class that the object must be converted to
        Returns:
        the newly converted object
        Throws:
        ConversionException - all exceptions will be thrown as this type.
      • convertObjectToBigDecimal

        protected BigDecimal convertObjectToBigDecimal​(Object sourceObject)
                                                throws ConversionException
        Build a valid instance of BigDecimal from the given sourceObject
        Parameters:
        sourceObject - Valid instance of String, BigInteger, any Number
        Throws:
        ConversionException
      • convertObjectToBigInteger

        protected BigInteger convertObjectToBigInteger​(Object sourceObject)
                                                throws ConversionException
        Build a valid instance of BigInteger from the provided sourceObject.
        Parameters:
        sourceObject - Valid instance of String, BigDecimal, or any Number
        Throws:
        ConversionException
      • convertObjectToBoolean

        protected Boolean convertObjectToBoolean​(Object sourceObject)
        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)
      • convertObjectToByte

        protected Byte convertObjectToByte​(Object sourceObject)
                                    throws ConversionException
        Build a valid instance of Byte from the provided sourceObject
        Parameters:
        sourceObject - Valid instance of String or any Number
        Throws:
        ConversionException - The Byte(String) constructor throws a NumberFormatException if the String does not contain a parsable byte.
      • convertObjectToByteArray

        protected byte[] convertObjectToByteArray​(Object sourceObject)
                                           throws ConversionException
        Build a valid instance of a byte array from the given object. This method does hex conversion of the string values. Some databases have problems with storing blobs unless the blob is stored as a hex string.
        Throws:
        ConversionException
      • convertObjectToByteObjectArray

        protected Byte[] convertObjectToByteObjectArray​(Object sourceObject)
                                                 throws ConversionException
        Build a valid instance of a Byte array from the given object. This method does hex conversion of the string values. Some databases have problems with storing blobs unless the blob is stored as a hex string.
        Throws:
        ConversionException
      • convertObjectToCalendar

        protected Calendar convertObjectToCalendar​(Object sourceObject)
                                            throws ConversionException
        Build a valid instance of java.util.Calendar from the given source object.
        Parameters:
        sourceObject - Valid instance of java.util.Date, String, java.sql.Timestamp, or Long
        Throws:
        ConversionException
      • convertObjectToChar

        protected Character convertObjectToChar​(Object sourceObject)
                                         throws ConversionException
        Build a valid instance of Character from the provided sourceObject.
        Parameters:
        sourceObject - Valid instance of String or any Number
        Throws:
        ConversionException
      • convertObjectToClass

        protected Class convertObjectToClass​(Object sourceObject)
                                      throws ConversionException
        Build a valid Class from the string that is passed in
        Parameters:
        sourceObject - Valid instance of String
        Throws:
        ConversionException
      • convertObjectToDate

        protected Date convertObjectToDate​(Object sourceObject)
                                    throws ConversionException
        Convert the object to an instance of java.sql.Date.
        Parameters:
        sourceObject - Object of type java.sql.Timestamp, java.util.Date, String or Long
        Throws:
        ConversionException
      • convertObjectToDouble

        protected Double convertObjectToDouble​(Object sourceObject)
                                        throws ConversionException
        Convert the object to an instance of Double.
        Parameters:
        sourceObject - Object of type String or Number.
        Throws:
        ConversionException - The Double(String) constructor throws a NumberFormatException if the String does not contain a parsable double.
      • convertObjectToFloat

        protected Float convertObjectToFloat​(Object sourceObject)
                                      throws ConversionException
        Build a valid Float instance from a String or another Number instance.
        Throws:
        ConversionException - The Float(String) constructor throws a NumberFormatException if the String does not contain a parsable Float.
      • convertObjectToInteger

        protected Integer convertObjectToInteger​(Object sourceObject)
                                          throws ConversionException
        Build a valid Integer instance from a String or another Number instance.
        Throws:
        ConversionException - The Integer(String) constructor throws a NumberFormatException if the String does not contain a parsable integer.
      • convertObjectToLong

        protected Long convertObjectToLong​(Object sourceObject)
                                    throws ConversionException
        Build a valid Long instance from a String or another Number instance.
        Throws:
        ConversionException - The Long(String) constructor throws a NumberFormatException if the String does not contain a parsable long.
      • convertObjectToNumber

        protected BigDecimal convertObjectToNumber​(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.
        Throws:
        ConversionException - The BigDecimal(String) constructor throws a NumberFormatException if the String does not contain a parsable BigDecimal.
      • convertObjectToShort

        protected Short convertObjectToShort​(Object sourceObject)
                                      throws ConversionException
        INTERNAL: Build a valid Short instance from a String or another Number instance.
        Throws:
        ConversionException - The Short(String) constructor throws a NumberFormatException if the String does not contain a parsable short.
      • convertObjectToString

        protected String convertObjectToString​(Object sourceObject)
                                        throws ConversionException
        INTERNAL: Converts objects to their string representations. java.util.Date is converted to a timestamp first and then to a string. An array of bytes is converted to a hex string.
        Throws:
        ConversionException
      • convertObjectToTime

        protected Time convertObjectToTime​(Object sourceObject)
                                    throws ConversionException
        INTERNAL: Build a valid instance of java.sql.Time from the given source object.
        Parameters:
        sourceObject - Valid instance of java.sql.Time, String, java.util.Date, java.sql.Timestamp, or Long
        Throws:
        ConversionException
      • convertObjectToTimestamp

        protected Timestamp convertObjectToTimestamp​(Object sourceObject)
                                              throws ConversionException
        INTERNAL: Build a valid instance of java.sql.Timestamp from the given source object.
        Parameters:
        sourceObject - Valid object of class java.sql.Timestamp, String, java.util.Date, or Long
        Throws:
        ConversionException
      • convertObjectToLocalDate

        protected LocalDate convertObjectToLocalDate​(Object sourceObject)
                                              throws ConversionException
        INTERNAL: Build a valid instance of java.time.LocalDate from the given source object.
        Parameters:
        sourceObject - Valid object of class java.sql.Timestamp, String, java.util.Date, or Long
        Throws:
        ConversionException
      • convertObjectToLocalTime

        protected LocalTime convertObjectToLocalTime​(Object sourceObject)
                                              throws ConversionException
        INTERNAL: Build a valid instance of java.time.LocalTime from the given source object.
        Parameters:
        sourceObject - Valid object of class java.sql.Timestamp, String, java.util.Date, or Long
        Throws:
        ConversionException
      • convertObjectToLocalDateTime

        protected LocalDateTime convertObjectToLocalDateTime​(Object sourceObject)
                                                      throws ConversionException
        INTERNAL: Build a valid instance of java.time.LocalDateTime from the given source object.
        Parameters:
        sourceObject - Valid object of class java.sql.Timestamp, String, java.util.Date, or Long
        Throws:
        ConversionException
      • convertObjectToOffsetDateTime

        protected OffsetDateTime convertObjectToOffsetDateTime​(Object sourceObject)
                                                        throws ConversionException
        INTERNAL: Build a valid instance of java.time.OffsetDateTime from the given source object.
        Parameters:
        sourceObject - Valid object of class java.sql.Timestamp, String, java.util.Date, or Long
        Throws:
        ConversionException
      • convertObjectToOffsetTime

        protected OffsetTime convertObjectToOffsetTime​(Object sourceObject)
                                                throws ConversionException
        INTERNAL: Build a valid instance of java.time.OffsetTime from the given source object.
        Parameters:
        sourceObject - Valid object of class java.sql.Timestamp, String, java.util.Date, or Long
        Throws:
        ConversionException
      • convertObjectToUrl

        protected URL convertObjectToUrl​(Object sourceObject)
                                  throws ConversionException
        INTERNAL: Build a valid instance of java.net.URL from the given source object.
        Parameters:
        sourceObject - Valid instance of java.net.URL, or String
        Throws:
        ConversionException
      • convertObjectToUtilDate

        protected Date convertObjectToUtilDate​(Object sourceObject)
                                        throws ConversionException
        INTERNAL: Build a valid instance of java.util.Date from the given source object.
        Parameters:
        sourceObject - Valid instance of java.util.Date, String, java.sql.Timestamp, or Long
        Throws:
        ConversionException
      • getDefaultManager

        public static ConversionManager getDefaultManager()
        A singleton conversion manager is used to handle generic conversions. This should not be used for conversion under the session context, these must go through the platform. This allows for the singleton to be customized through setting the default to a user defined subclass.
      • getDefaultNullValue

        public Object getDefaultNullValue​(Class theClass)
        INTERNAL: Allow for the null values for classes to be defaulted in one place. Any nulls read from the database to be converted to the class will be given the specified null value.
      • getDefaultNullValues

        public Map getDefaultNullValues()
        INTERNAL: Allow for the null values for classes to be defaulted in one place. Any nulls read from the database to be converted to the class will be given the specified null value.
      • hasDefaultNullValues

        public boolean hasDefaultNullValues()
        INTERNAL
      • loadClass

        public static Class loadClass​(String className)
        INTERNAL: Load the class using the default managers class loader. This is a thread based class loader by default. This should be used to load all classes as Class.forName can only see classes on the same classpath as the eclipselink.jar.
      • getObjectClass

        public static Class getObjectClass​(Class javaClass)
        INTERNAL: This is used to determine the wrapper class for a primitive.
      • getPrimitiveClass

        public static Class getPrimitiveClass​(String classType)
        INTERNAL: Returns a class based on the passed in string.
      • setDefaultManager

        public static void setDefaultManager​(ConversionManager theManager)
        A singleton conversion manager is used to handle generic conversions. This should not be used for conversion under the session context, these must go through the platform. This allows for the singleton to be customized through setting the default to a user defined subclass.
      • setDefaultNullValue

        public void setDefaultNullValue​(Class theClass,
                                        Object theValue)
        INTERNAL: Allow for the null values for classes to be defaulted in one place. Any nulls read from the database to be converted to the class will be given the specified null value. Primitive null values should be set to the wrapper class.
      • setDefaultNullValues

        public void setDefaultNullValues​(Map defaultNullValues)
        INTERNAL: Allow for the null values for classes to be defaulted in one place. Any nulls read from the database to be converted to the class will be given the specified null value.
      • setLoader

        public void setLoader​(ClassLoader classLoader)
        INTERNAL:
        Parameters:
        classLoader -
      • setDefaultLoader

        public static void setDefaultLoader​(ClassLoader classLoader)
        INTERNAL: Set the default class loader to use if no instance-level loader is set
        Parameters:
        classLoader -
      • getDefaultLoader

        public static ClassLoader getDefaultLoader()
        INTERNAL: Get the default class loader to use if no instance-level loader is set
        Returns:
        java.lang.ClassLoader
      • setShouldUseClassLoaderFromCurrentThread

        public void setShouldUseClassLoaderFromCurrentThread​(boolean useCurrentThread)
        ADVANCED: This flag should be set if the current thread classLoader should be used. This is the case in certain Application Servers were the class loader must be retrieved from the current Thread. If classNotFoundExceptions are being thrown then set this flag. In certain cases it will resolve the problem
      • shouldUseClassLoaderFromCurrentThread

        public boolean shouldUseClassLoaderFromCurrentThread()
        ADVANCED: This flag should be set if the current thread classLoader should be used. This is the case in certain Application Servers were the class loader must be retrieved from the current Thread. If classNotFoundExceptions are being thrown then set this flag. In certain cases it will resolve the problem
      • getDataTypesConvertedFrom

        public Vector getDataTypesConvertedFrom​(Class javaClass)
        PUBLIC: Return the list of Classes that can be converted to from the passed in javaClass.
        Parameters:
        javaClass - - the class that is converted from
        Returns:
        - a vector of classes
      • getDataTypesConvertedTo

        public Vector getDataTypesConvertedTo​(Class javaClass)
        PUBLIC: Return the list of Classes that can be converted from to the passed in javaClass.
        Parameters:
        javaClass - - the class that is converted to
        Returns:
        - a vector of classes
      • buildNumberVec

        protected Vector buildNumberVec()
      • buildDateTimeVec

        protected Vector buildDateTimeVec()
      • buildDataTypesConvertedFromAClass

        protected void buildDataTypesConvertedFromAClass()
      • buildFromBooleanVec

        protected Vector buildFromBooleanVec()
      • buildFromNumberVec

        protected Vector buildFromNumberVec()
      • buildFromBigDecimalVec

        protected Vector buildFromBigDecimalVec()
      • buildFromBigIntegerVec

        protected Vector buildFromBigIntegerVec()
      • buildFromIntegerVec

        protected Vector buildFromIntegerVec()
      • buildFromFloatVec

        protected Vector buildFromFloatVec()
      • buildFromDoubleVec

        protected Vector buildFromDoubleVec()
      • buildFromShortVec

        protected Vector buildFromShortVec()
      • buildFromByteVec

        protected Vector buildFromByteVec()
      • buildFromLongVec

        protected Vector buildFromLongVec()
      • buildFromStringVec

        protected Vector buildFromStringVec()
      • buildFromCharacterVec

        protected Vector buildFromCharacterVec()
      • buildFromByteArrayVec

        protected Vector buildFromByteArrayVec()
      • buildFromClobVec

        protected Vector buildFromClobVec()
      • buildFromBlobVec

        protected Vector buildFromBlobVec()
      • buildFromUtilDateVec

        protected Vector buildFromUtilDateVec()
      • buildFromTimestampVec

        protected Vector buildFromTimestampVec()
      • buildFromCalendarVec

        protected Vector buildFromCalendarVec()
      • buildFromDateVec

        protected Vector buildFromDateVec()
      • buildFromTimeVec

        protected Vector buildFromTimeVec()
      • buildFromByteObjectArraryVec

        protected Vector buildFromByteObjectArraryVec()
      • buildFromCharArrayVec

        protected Vector buildFromCharArrayVec()
      • buildFromCharacterArrayVec

        protected Vector buildFromCharacterArrayVec()
      • buildDataTypesConvertedToAClass

        protected void buildDataTypesConvertedToAClass()
      • buildAllTypesToAClassVec

        protected Vector buildAllTypesToAClassVec()
      • buildToBigDecimalVec

        protected Vector buildToBigDecimalVec()
      • buildToBigIntegerVec

        protected Vector buildToBigIntegerVec()
      • buildToBooleanVec

        protected Vector buildToBooleanVec()
      • buildToByteVec

        protected Vector buildToByteVec()
      • buildToDoubleVec

        protected Vector buildToDoubleVec()
      • buildToFloatVec

        protected Vector buildToFloatVec()
      • buildToIntegerVec

        protected Vector buildToIntegerVec()
      • buildToLongVec

        protected Vector buildToLongVec()
      • buildToNumberVec

        protected Vector buildToNumberVec()
      • buildToShortVec

        protected Vector buildToShortVec()
      • buildToByteArrayVec

        protected Vector buildToByteArrayVec()
      • buildToByteObjectArrayVec

        protected Vector buildToByteObjectArrayVec()
      • buildToCharacterVec

        protected Vector buildToCharacterVec()
      • buildToCharacterArrayVec

        protected Vector buildToCharacterArrayVec()
      • buildToCharArrayVec

        protected Vector buildToCharArrayVec()
      • buildToStringVec

        protected Vector buildToStringVec()
      • buildToCalendarVec

        protected Vector buildToCalendarVec()
      • buildToTimestampVec

        protected Vector buildToTimestampVec()
      • buildToUtilDateVec

        protected Vector buildToUtilDateVec()
      • buildToDateVec

        protected Vector buildToDateVec()
      • buildToTimeVec

        protected Vector buildToTimeVec()
      • buildToBlobVec

        protected Vector buildToBlobVec()
      • buildToClobVec

        protected Vector buildToClobVec()