getType()

Determines the data type of a value.

Syntax

int getType(Object objectData)
 int getType(int integerData)
 int getType(float floatData)
 int getType(double doubleData)
 int getType(boolean booleanData)
 

Parameters

objectData
Any Java object.

integerData
Any primitive int variable.

floatData
Any primitive float variable.

doubleData
Any primitive double variable.

booleanData
Any primitive boolean variable.

Return values

Returns an integer representing the data type of the parameter you pass. You can interpret the return value by comparing it to one of these constants which are declared as static and final in the DtpDataConversion class:

INTEGER_TYPE
The data is a primitive int value or Integer object.

STRING_TYPE
The data is a String object.

FLOAT_TYPE
The data is a primitive float value or Float object.

DOUBLE_TYPE
The data is a primitive double value or Double object.

BOOL_TYPE
The data is a primitive boolean value or Boolean object.

DATE_TYPE
The data is a Date object.

LONGTEXT_TYPE
The data is a LongText object.

UNKNOWN_TYPE
The data is of an unknown type.

Exceptions

None.

Notes

You can use the return values from getType() in the OKToConvert() method to determine whether a conversion is possible between two given data types.

Examples

int conversionStatus = DtpDataConversion.isOKToConvert(
    DtpDataConversion.getType(srcObject),
    DtpDataConversion.getType(destObject));
  
 switch(conversionStatus)
    {
    case DtpDataConversion.OKTOCONVERT:
       // go ahead and convert
       break;
    case DtpDataConversion.POTENTIALDATALOSS:
       // convert, then check value
       break;
    case DtpDataConversion.CANNOTCONVERT:
       // return an error
       break;
 }
 

See also

isOKToConvert()

Copyright IBM Corp. 1997, 2003