org.apache.commons.jexl.util
Class Coercion

java.lang.Object
  |
  +--org.apache.commons.jexl.util.Coercion

public class Coercion
extends Object

Coercion utilities for the JSTL EL-like coercion.

Since:
1.0

Constructor Summary
Coercion()
           
 
Method Summary
static Boolean coerceBoolean(Object val)
          Coerce to a Boolean.
static Double coerceDouble(Object val)
          Coerce to a Double.
static Integer coerceInteger(Object val)
          Coerce to a Integer.
static Long coerceLong(Object val)
          Coerce to a Long.
static boolean isFloatingPoint(Object o)
          Is Object a floating point number.
static boolean isNumberable(Object o)
          Is Object a whole number.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Coercion

public Coercion()
Method Detail

coerceBoolean

public static Boolean coerceBoolean(Object val)
Coerce to a Boolean.

Parameters:
val - Object to be coerced.
Returns:
The Boolean coerced value, or null if none possible.

coerceInteger

public static Integer coerceInteger(Object val)
                             throws Exception
Coerce to a Integer.

Parameters:
val - Object to be coerced.
Returns:
The Integer coerced value.
Throws:
Exception - If Integer coercion fails.

coerceLong

public static Long coerceLong(Object val)
                       throws Exception
Coerce to a Long.

Parameters:
val - Object to be coerced.
Returns:
The Long coerced value.
Throws:
Exception - If Long coercion fails.

coerceDouble

public static Double coerceDouble(Object val)
                           throws Exception
Coerce to a Double.

Parameters:
val - Object to be coerced.
Returns:
The Double coerced value.
Throws:
Exception - If Double coercion fails.

isFloatingPoint

public static boolean isFloatingPoint(Object o)
Is Object a floating point number.

Parameters:
o - Object to be analyzed.
Returns:
true if it is a Float or a Double.

isNumberable

public static boolean isNumberable(Object o)
Is Object a whole number.

Parameters:
o - Object to be analyzed.
Returns:
true if Integer, Long, Byte, Short or Character.


Copyright © 2003-2006 The Apache Software Foundation. All Rights Reserved.