Package de.uplanet.lucy.types
Class Cast
- java.lang.Object
-
- de.uplanet.lucy.types.Cast
-
@Scriptable public final class Cast extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static BigDecimal
toBigDecimal(Number p_value)
This method callstoBigDecimal(Number, MathContext)
with aMathContext.UNLIMITED
as math context.static BigDecimal
toBigDecimal(Number p_value, MathContext p_mathContext)
Cast the given number tojava.math.BigDecimal
.static boolean
toBoolean(Number p_value)
Cast an integral number with value in{0, 1}
toboolean
.static byte
toByte(Number p_value)
static double
toDouble(Number p_value)
static float
toFloat(Number p_value)
static int
toInt(Number p_value)
static long
toLong(Number p_value)
static short
toShort(Number p_value)
-
-
-
Method Detail
-
toBoolean
public static boolean toBoolean(Number p_value)
Cast an integral number with value in{0, 1}
toboolean
.- Parameters:
p_value
- The integral number.- Returns:
true
if the given value is1
, orfalse
if the given value is0
.- Throws:
IllegalArgumentException
- Ifp_value
isnull
, or not of an integral data type.ArithmeticException
- If the given value is not in{0, 1}
.
-
toByte
public static byte toByte(Number p_value)
-
toShort
public static short toShort(Number p_value)
-
toInt
public static int toInt(Number p_value)
-
toLong
public static long toLong(Number p_value)
-
toFloat
public static float toFloat(Number p_value)
-
toDouble
public static double toDouble(Number p_value)
-
toBigDecimal
public static BigDecimal toBigDecimal(Number p_value)
This method callstoBigDecimal(Number, MathContext)
with aMathContext.UNLIMITED
as math context.- Parameters:
p_value
- The number.- Returns:
- The given number cast to
java.math.BigDecimal
. - Throws:
IllegalArgumentException
- Ifp_value
isnull
.
-
toBigDecimal
public static BigDecimal toBigDecimal(Number p_value, MathContext p_mathContext)
Cast the given number tojava.math.BigDecimal
.- Parameters:
p_value
- The number.p_mathContext
- The math context to be used.- Returns:
- The given number cast to
java.math.BigDecimal
. - Throws:
IllegalArgumentException
- Ifp_value
isnull
.
-
-