org.apache.commons.el
Class Coercions

java.lang.Object
  extended by org.apache.commons.el.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: bayard $
Author:
Nathan Abramson - Art Technology Group

Constructor Summary
Coercions()
           
 
Method Summary
static Object applyArithmeticOperator(Object pLeft, Object pRight, ArithmeticOperator pOperator)
          Performs all of the necessary type conversions, then calls on the appropriate operator.
static Object applyEqualityOperator(Object pLeft, Object pRight, EqualityOperator pOperator)
          Performs all of the necessary type conversions, then calls on the appropriate operator.
static Object applyRelationalOperator(Object pLeft, Object pRight, RelationalOperator pOperator)
          Performs all of the necessary type conversions, then calls on the appropriate operator.
static Object coerce(Object pValue, Class pClass)
          Coerces the given value to the specified class.
static Boolean coerceToBoolean(Object pValue)
          Coerces a value to a Boolean
static Character coerceToCharacter(Object pValue)
          Coerces a value to a Character
static Integer coerceToInteger(Object pValue)
          Coerces a value to an Integer, returning null if the coercion isn't possible.
static Object coerceToObject(Object pValue, Class pClass)
          Coerces a value to the specified Class that is not covered by any of the above cases
static Number coerceToPrimitiveNumber(Object pValue, Class pClass)
          Coerces a value to the given primitive number class
static String coerceToString(Object pValue)
          Coerces the specified value to a String
static boolean isBigDecimal(Object pObject)
          Returns true if the given object is BigDecimal.
static boolean isBigInteger(Object pObject)
          Returns true if the given object is BigInteger.
static boolean isFloatingPointString(Object pObject)
          Returns true if the given string might contain a floating point number - i.e., it contains ".", "e", or "E"
static boolean isFloatingPointType(Class pClass)
          Returns true if the given class is of a floating point type
static boolean isFloatingPointType(Object pObject)
          Returns true if the given Object is of a floating point type
static boolean isIntegerType(Class pClass)
          Returns true if the given class is of an integer type
static boolean isIntegerType(Object pObject)
          Returns true if the given Object is of an integer type
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Coercions

public Coercions()
Method Detail

coerce

public static Object coerce(Object pValue,
                            Class pClass)
                     throws javax.servlet.jsp.el.ELException
Coerces the given value to the specified class.

Throws:
javax.servlet.jsp.el.ELException

coerceToString

public static String coerceToString(Object pValue)
                             throws javax.servlet.jsp.el.ELException
Coerces the specified value to a String

Throws:
javax.servlet.jsp.el.ELException

coerceToPrimitiveNumber

public static Number coerceToPrimitiveNumber(Object pValue,
                                             Class pClass)
                                      throws javax.servlet.jsp.el.ELException
Coerces a value to the given primitive number class

Throws:
javax.servlet.jsp.el.ELException

coerceToInteger

public static Integer coerceToInteger(Object pValue)
                               throws javax.servlet.jsp.el.ELException
Coerces a value to an Integer, returning null if the coercion isn't possible.

Throws:
javax.servlet.jsp.el.ELException

coerceToCharacter

public static Character coerceToCharacter(Object pValue)
                                   throws javax.servlet.jsp.el.ELException
Coerces a value to a Character

Throws:
javax.servlet.jsp.el.ELException

coerceToBoolean

public static Boolean coerceToBoolean(Object pValue)
                               throws javax.servlet.jsp.el.ELException
Coerces a value to a Boolean

Throws:
javax.servlet.jsp.el.ELException

coerceToObject

public static Object coerceToObject(Object pValue,
                                    Class pClass)
                             throws javax.servlet.jsp.el.ELException
Coerces a value to the specified Class that is not covered by any of the above cases

Throws:
javax.servlet.jsp.el.ELException

applyArithmeticOperator

public static Object applyArithmeticOperator(Object pLeft,
                                             Object pRight,
                                             ArithmeticOperator pOperator)
                                      throws javax.servlet.jsp.el.ELException
Performs all of the necessary type conversions, then calls on the appropriate operator.

Throws:
javax.servlet.jsp.el.ELException

applyRelationalOperator

public static Object applyRelationalOperator(Object pLeft,
                                             Object pRight,
                                             RelationalOperator pOperator)
                                      throws javax.servlet.jsp.el.ELException
Performs all of the necessary type conversions, then calls on the appropriate operator.

Throws:
javax.servlet.jsp.el.ELException

applyEqualityOperator

public static Object applyEqualityOperator(Object pLeft,
                                           Object pRight,
                                           EqualityOperator pOperator)
                                    throws javax.servlet.jsp.el.ELException
Performs all of the necessary type conversions, then calls on the appropriate operator.

Throws:
javax.servlet.jsp.el.ELException

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


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"


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


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

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


Copyright © 2003-2011 Apache Software Foundation. All Rights Reserved.