Package com.polarion.core.util.types
Class ConversionHelper
java.lang.Object
com.polarion.core.util.types.ConversionHelper
Helper for type conversions.
The general contract applied for the conversion methods of this class is that
- when
object
isnull
,defaultValue
is returned - when
object
is an instance of the desired type, reference to it is returned - when the conversion fails,
defaultValue
is returned null
is returned only in the case when bothobject
anddefaultValue
are null
- Version:
- $Revision: 1.3 $ $Date: 2003/12/29 18:58:51 $
- Author:
- Ondrej Chylik, Polarion Software
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
getBoolean
(Object object, boolean defaultValue) Converts an object to primitive boolean type.static Boolean
getBoolean
(Object object, Boolean defaultValue) Converts an object toBoolean
.static byte
Converts an object to primitive byte type.static Byte
Converts an object toByte
.static double
Converts an object to primitive double type.static Double
Converts an object toDouble
.static float
Converts an object to primitive float type.static Float
Converts an object toFloat
.static int
Converts an object to primitive int type.static Integer
getIntenger
(Object object, Integer defaultValue) Converts an object toInteger
.static long
Converts an object to primitive long type.static Long
Converts an object toLong
.static Object
Converts an object to the specified type.static short
Converts an object to primitive short type.static Short
Converts an object toShort
.static String
Converts an object to string.
-
Method Details
-
getString
Converts an object to string. -
getObject
Converts an object to the specified type.Note: Default value which is not an instance of the given type is an invalid argument for this method.
-
getBoolean
Converts an object to primitive boolean type. String to boolean conversion applies to values"true"
,"on"
or"yes"
and"false"
,"off"
or"no"
, case insensitive. -
getInt
Converts an object to primitive int type. Applies to any instance ofNumber
or to strings. -
getLong
Converts an object to primitive long type. Applies to any instance ofNumber
or to strings. -
getFloat
Converts an object to primitive float type. Applies to any instance ofNumber
or to strings. -
getDouble
Converts an object to primitive double type. Applies to any instance ofNumber
or to strings. -
getByte
Converts an object to primitive byte type. Applies to any instance ofNumber
or to strings. -
getShort
Converts an object to primitive short type. Applies to any instance ofNumber
or to strings. -
getBoolean
Converts an object toBoolean
. String to boolean conversion applies to values"true"
,"on"
or"yes"
and"false"
,"off"
or"no"
, case insensitive. -
getIntenger
Converts an object toInteger
. Applies to any instance ofNumber
or to strings. -
getLong
Converts an object toLong
. Applies to any instance ofNumber
or to strings. -
getFloat
Converts an object toFloat
. Applies to any instance ofNumber
or to strings. -
getDouble
Converts an object toDouble
. Applies to any instance ofDouble
or to strings. -
getByte
Converts an object toByte
. Applies to any instance ofNumber
or to strings. -
getShort
Converts an object toShort
. Applies to any instance ofNumber
or to strings.
-