org.apache.commons.el

Class Coercions

public class Coercions extends Object

This class contains the logic for coercing data types before operators are applied to them.

The following is the list of rules applied for various type conversions.

Version: $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $

Author: Nathan Abramson - Art Technology Group

Field Summary
static NumberZERO
Method Summary
static ObjectapplyArithmeticOperator(Object pLeft, Object pRight, ArithmeticOperator pOperator, Logger pLogger)
Performs all of the necessary type conversions, then calls on the appropriate operator.
static ObjectapplyEqualityOperator(Object pLeft, Object pRight, EqualityOperator pOperator, Logger pLogger)
Performs all of the necessary type conversions, then calls on the appropriate operator.
static ObjectapplyRelationalOperator(Object pLeft, Object pRight, RelationalOperator pOperator, Logger pLogger)
Performs all of the necessary type conversions, then calls on the appropriate operator.
static Objectcoerce(Object pValue, Class pClass, Logger pLogger)
Coerces the given value to the specified class.
static BooleancoerceToBoolean(Object pValue, Logger pLogger)
Coerces a value to a Boolean
static CharactercoerceToCharacter(Object pValue, Logger pLogger)
Coerces a value to a Character
static IntegercoerceToInteger(Object pValue, Logger pLogger)
Coerces a value to an Integer, returning null if the coercion isn't possible.
static ObjectcoerceToObject(Object pValue, Class pClass, Logger pLogger)
Coerces a value to the specified Class that is not covered by any of the above cases
static NumbercoerceToPrimitiveNumber(Object pValue, Class pClass, Logger pLogger)
Coerces a value to the given primitive number class
static NumbercoerceToPrimitiveNumber(long pValue, Class pClass)
Coerces a long to the given primitive number class
static NumbercoerceToPrimitiveNumber(double pValue, Class pClass)
Coerces a double to the given primitive number class
static NumbercoerceToPrimitiveNumber(Number pValue, Class pClass)
Coerces a Number to the given primitive number class
static NumbercoerceToPrimitiveNumber(String pValue, Class pClass)
Coerces a String to the given primitive number class
static StringcoerceToString(Object pValue, Logger pLogger)
Coerces the specified value to a String
static booleanisBigDecimal(Object pObject)
Returns true if the given object is BigDecimal.
static booleanisBigInteger(Object pObject)
Returns true if the given object is BigInteger.
static booleanisFloatingPointString(Object pObject)
Returns true if the given string might contain a floating point number - i.e., it contains ".", "e", or "E"
static booleanisFloatingPointType(Object pObject)
Returns true if the given Object is of a floating point type
static booleanisFloatingPointType(Class pClass)
Returns true if the given class is of a floating point type
static booleanisIntegerType(Object pObject)
Returns true if the given Object is of an integer type
static booleanisIntegerType(Class pClass)
Returns true if the given class is of an integer type
static booleanisNumberClass(Class pClass)
Returns true if the given class is Byte, Short, Integer, Long, Float, Double, BigInteger, or BigDecimal

Field Detail

ZERO

private static final Number ZERO

Method Detail

applyArithmeticOperator

public static Object applyArithmeticOperator(Object pLeft, Object pRight, ArithmeticOperator pOperator, Logger pLogger)
Performs all of the necessary type conversions, then calls on the appropriate operator.

applyEqualityOperator

public static Object applyEqualityOperator(Object pLeft, Object pRight, EqualityOperator pOperator, Logger pLogger)
Performs all of the necessary type conversions, then calls on the appropriate operator.

applyRelationalOperator

public static Object applyRelationalOperator(Object pLeft, Object pRight, RelationalOperator pOperator, Logger pLogger)
Performs all of the necessary type conversions, then calls on the appropriate operator.

coerce

public static Object coerce(Object pValue, Class pClass, Logger pLogger)
Coerces the given value to the specified class.

coerceToBoolean

public static Boolean coerceToBoolean(Object pValue, Logger pLogger)
Coerces a value to a Boolean

coerceToCharacter

public static Character coerceToCharacter(Object pValue, Logger pLogger)
Coerces a value to a Character

coerceToInteger

public static Integer coerceToInteger(Object pValue, Logger pLogger)
Coerces a value to an Integer, returning null if the coercion isn't possible.

coerceToObject

public static Object coerceToObject(Object pValue, Class pClass, Logger pLogger)
Coerces a value to the specified Class that is not covered by any of the above cases

coerceToPrimitiveNumber

public static Number coerceToPrimitiveNumber(Object pValue, Class pClass, Logger pLogger)
Coerces a value to the given primitive number class

coerceToPrimitiveNumber

static Number coerceToPrimitiveNumber(long pValue, Class pClass)
Coerces a long to the given primitive number class

coerceToPrimitiveNumber

static Number coerceToPrimitiveNumber(double pValue, Class pClass)
Coerces a double to the given primitive number class

coerceToPrimitiveNumber

static Number coerceToPrimitiveNumber(Number pValue, Class pClass)
Coerces a Number to the given primitive number class

coerceToPrimitiveNumber

static Number coerceToPrimitiveNumber(String pValue, Class pClass)
Coerces a String to the given primitive number class

coerceToString

public static String coerceToString(Object pValue, Logger pLogger)
Coerces the specified value to a String

isBigDecimal

public static boolean isBigDecimal(Object pObject)
Returns true if the given object is BigDecimal.

Parameters: pObject - Object to evaluate

Returns: - true if the given object is BigDecimal

isBigInteger

public static boolean isBigInteger(Object pObject)
Returns true if the given object is BigInteger.

Parameters: pObject - Object to evaluate

Returns: - true if the given object is BigInteger

isFloatingPointString

public static boolean isFloatingPointString(Object pObject)
Returns true if the given string might contain a floating point number - i.e., it contains ".", "e", or "E"

isFloatingPointType

public static boolean isFloatingPointType(Object pObject)
Returns true if the given Object is of a floating point type

isFloatingPointType

public static boolean isFloatingPointType(Class pClass)
Returns true if the given class is of a floating point type

isIntegerType

public static boolean isIntegerType(Object pObject)
Returns true if the given Object is of an integer type

isIntegerType

public static boolean isIntegerType(Class pClass)
Returns true if the given class is of an integer type

isNumberClass

static boolean isNumberClass(Class pClass)
Returns true if the given class is Byte, Short, Integer, Long, Float, Double, BigInteger, or BigDecimal
Copyright (c) 2001-2002 - Apache Software Foundation