org.apache.commons.jexl.util

Class Coercion

public class Coercion extends Object

Coercion utilities for the JSTL EL-like coercion.

Since: 1.0

Method Summary
static BooleancoerceBoolean(Object val)
Coerce to a Boolean.
static DoublecoerceDouble(Object val)
Coerce to a Double.
static IntegercoerceInteger(Object val)
Coerce to a Integer.
static LongcoerceLong(Object val)
Coerce to a Long.
static booleanisFloatingPoint(Object o)
Is Object a floating point number.
static booleanisNumberable(Object o)
Is Object a whole number.

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.

coerceDouble

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

Parameters: val Object to be coerced.

Returns: The Double coerced value.

Throws: Exception If Double coercion fails.

coerceInteger

public static Integer coerceInteger(Object val)
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)
Coerce to a Long.

Parameters: val Object to be coerced.

Returns: The Long coerced value.

Throws: Exception If Long 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-2010 The Apache Software Foundation. All Rights Reserved.