org.apache.commons.el
Class Coercions

java.lang.Object
  |
  +--org.apache.commons.el.Coercions

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

Field Detail

ZERO

private static final java.lang.Number ZERO
Constructor Detail

Coercions

public Coercions()
Method Detail

coerce

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

javax.servlet.jsp.el.ELException

isNumberClass

static boolean isNumberClass(java.lang.Class pClass)
Returns true if the given class is Byte, Short, Integer, Long, Float, Double, BigInteger, or BigDecimal


coerceToString

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

javax.servlet.jsp.el.ELException

coerceToPrimitiveNumber

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

javax.servlet.jsp.el.ELException

coerceToInteger

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

javax.servlet.jsp.el.ELException

coerceToPrimitiveNumber

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

javax.servlet.jsp.el.ELException

coerceToPrimitiveNumber

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

javax.servlet.jsp.el.ELException

coerceToPrimitiveNumber

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

javax.servlet.jsp.el.ELException

coerceToPrimitiveNumber

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

javax.servlet.jsp.el.ELException

coerceToCharacter

public static java.lang.Character coerceToCharacter(java.lang.Object pValue,
                                                    Logger pLogger)
                                             throws javax.servlet.jsp.el.ELException
Coerces a value to a Character

javax.servlet.jsp.el.ELException

coerceToBoolean

public static java.lang.Boolean coerceToBoolean(java.lang.Object pValue,
                                                Logger pLogger)
                                         throws javax.servlet.jsp.el.ELException
Coerces a value to a Boolean

javax.servlet.jsp.el.ELException

coerceToObject

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

javax.servlet.jsp.el.ELException

applyArithmeticOperator

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

javax.servlet.jsp.el.ELException

applyRelationalOperator

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

javax.servlet.jsp.el.ELException

applyEqualityOperator

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

javax.servlet.jsp.el.ELException

isFloatingPointType

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


isFloatingPointType

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


isFloatingPointString

public static boolean isFloatingPointString(java.lang.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(java.lang.Object pObject)
Returns true if the given Object is of an integer type


isIntegerType

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


isBigInteger

public static boolean isBigInteger(java.lang.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(java.lang.Object pObject)
Returns true if the given object is BigDecimal.

Parameters:
pObject - - Object to evaluate
Returns:
- true if the given object is BigDecimal


Copyright (c) 2001-2002 - Apache Software Foundation