Class Cast


  • @Scriptable
    public final class Cast
    extends Object
    • Method Detail

      • toBoolean

        public static boolean toBoolean​(Number p_value)
        Cast an integral number with value in {0, 1} to boolean.
        Parameters:
        p_value - The integral number.
        Returns:
        true if the given value is 1, or false if the given value is 0.
        Throws:
        IllegalArgumentException - If p_value is null, 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,
                                              MathContext p_mathContext)
        Cast the given number to java.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 - If p_value is null.