Example usage for org.apache.commons.el Coercions coerce

List of usage examples for org.apache.commons.el Coercions coerce

Introduction

In this page you can find the example usage for org.apache.commons.el Coercions coerce.

Prototype

public static Object coerce(Object pValue, Class pClass, Logger pLogger) throws ELException 

Source Link

Document

Coerces the given value to the specified class.

Usage

From source file:it.cilea.osd.jdyna.web.tag.ExpressionEvaluatorImpl.java

/**
 * //from   w  w  w .j  a v  a2  s  .c  o m
 * Converts the given value to the specified expected type.
 **/
Object convertToExpectedType(Object pValue, Class pExpectedType, Logger pLogger) throws ELException {
    return Coercions.coerce(pValue, pExpectedType, pLogger);
}

From source file:it.cilea.osd.jdyna.web.tag.ExpressionEvaluatorImpl.java

/**
 * /*from w  w  w.j  a va2s  .  co m*/
 * Converts the given String, specified as a static expression string, to
 * the given expected type. The conversion is cached.
 **/
Object convertStaticValueToExpectedType(String pValue, Class pExpectedType, Logger pLogger) throws ELException {
    // See if the value is already of the expected type
    if (pExpectedType == String.class || pExpectedType == Object.class) {
        return pValue;
    }

    // Convert from a String
    Object ret = Coercions.coerce(pValue, pExpectedType, pLogger);

    return ret;

}

From source file:com.googlecode.jsfFlex.myFaces.ClassUtils.java

public static Object convertToType(Object value, Class desiredClass) {
    if (value == null)
        return null;

    try {// w  ww .ja v  a 2  s .c o m
        // Use coersion implemented by JSP EL for consistency with EL
        // expressions. Additionally, it caches some of the coersions.
        return Coercions.coerce(value, desiredClass, COERCION_LOGGER);
    } catch (ELException e) {
        String message = "Cannot coerce " + value.getClass().getName() + " to " + desiredClass.getName();
        log.error(message, e);
        throw new FacesException(message, e);
    }
}

From source file:org.seasar.teeda.core.el.impl.commons.CoercionsUtil.java

public static Object coerce(Object newValue, Class type) throws EvaluationException {
    try {/*  w  ww.  j a v  a 2s.c o m*/
        return Coercions.coerce(newValue, type, CommonsElLogger.getLogger());
    } catch (ELException e) {
        throw new EvaluationException(e);
    }
}