DtpDataConversion class

One of the most common tasks in business object mapping is the conversion of attribute values from one data type to another, a process called data conversion. The DtpDataConversion class provides a simple way to perform data conversions.

The data type classes in the java.lang package contain some conversion methods, but all possible conversions are not supported. The DtpDataConversion class consolidates many data conversion methods into one class and it supports the most common conversions that you perform in maps. The getType() and isOKToConvert() methods make it easy to determine whether specific conversions are possible.

All methods in this class are declared as static. Table 99 summarizes the methods of the DtpDataConversion class.

Table 99.
DtpDataConversion method summary
Method Description Page
getType() Determines the data type of a value. getType()
isOKToConvert() Determines whether it is possible to convert a value from one data type to another. isOKToConvert()
toBoolean() Converts a Java object to a Boolean object. toBoolean()
toDouble() Converts an object or primitive data type to a Double object. toDouble()
toFloat() Converts an object or primitive data type to a Float object. toFloat()
toInteger() Converts an object or primitive data type to an Integer object. toInteger()
toPrimitiveBoolean() Converts a String or Boolean object to the primitive boolean data type. toPrimitiveBoolean()
toPrimitiveDouble() Converts an object or primitive data type to the primitive double data type. toPrimitiveDouble()
toPrimitiveFloat() Converts an object or primitive data type to the primitive float data type. toPrimitiveFloat()
toPrimitiveInt() Converts an object or primitive data type to the primitive int data type. toPrimitiveInt()
toString() Converts an object or primitive data type to a String object. toString()

Copyright IBM Corp. 1997, 2003