de.uplanet.lucy.types
Class Cast

java.lang.Object
  extended by de.uplanet.lucy.types.Cast

@Scriptable
public final class Cast
extends java.lang.Object

Version:
$Revision: 73078 $

Method Summary
static java.math.BigDecimal toBigDecimal(java.lang.Number p_value)
          This method calls toBigDecimal(Number, MathContext) with a MathContext.UNLIMITED as math context.
static java.math.BigDecimal toBigDecimal(java.lang.Number p_value, java.math.MathContext p_mathContext)
          Cast the given number to java.math.BigDecimal.
static boolean toBoolean(java.lang.Number p_value)
          Cast an integral number with value in {0, 1} to boolean.
static byte toByte(java.lang.Number p_value)
           
static double toDouble(java.lang.Number p_value)
           
static float toFloat(java.lang.Number p_value)
           
static int toInt(java.lang.Number p_value)
           
static long toLong(java.lang.Number p_value)
           
static short toShort(java.lang.Number p_value)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

toBoolean

public static boolean toBoolean(java.lang.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:
java.lang.IllegalArgumentException - If p_value is null, or not of an integral data type.
java.lang.ArithmeticException - If the given value is not in {0, 1}.

toByte

public static byte toByte(java.lang.Number p_value)

toShort

public static short toShort(java.lang.Number p_value)

toInt

public static int toInt(java.lang.Number p_value)

toLong

public static long toLong(java.lang.Number p_value)

toFloat

public static float toFloat(java.lang.Number p_value)

toDouble

public static double toDouble(java.lang.Number p_value)

toBigDecimal

public static java.math.BigDecimal toBigDecimal(java.lang.Number p_value)
This method calls toBigDecimal(Number, MathContext) with a MathContext.UNLIMITED as math context.

Parameters:
p_value - The number.
Returns:
The given number cast to java.math.BigDecimal.
Throws:
java.lang.IllegalArgumentException - If p_value is null.

toBigDecimal

public static java.math.BigDecimal toBigDecimal(java.lang.Number p_value,
                                                java.math.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:
java.lang.IllegalArgumentException - If p_value is null.


Last updated: 2011-08-11 10-04
Copyright © 2000-2011 United Planet. All Rights Reserved.