Example usage for org.apache.commons.el.parser ParseException getMessage

List of usage examples for org.apache.commons.el.parser ParseException getMessage

Introduction

In this page you can find the example usage for org.apache.commons.el.parser ParseException getMessage.

Prototype

public String getMessage() 

Source Link

Document

This method has the standard behavior when this object has been created using the standard constructors.

Usage

From source file:gov.nih.nci.cabig.caaers.utils.el.EL.java

public String evaluate(String input) {
    try {/*  w  w  w  .  ja v  a 2  s .c o  m*/
        StringReader rdr = new StringReader(input);
        ELParser parser = new ELParser(rdr);
        Object result = parser.ExpressionString();

        if (result instanceof String) {
            return (String) result;
        } else if (result instanceof Expression) {
            Expression expr = (Expression) result;
            result = expr.evaluate(this.resolver);
            return result == null ? null : result.toString();
        } else if (result instanceof ExpressionString) {
            Expression expr = (Expression) result;
            result = expr.evaluate(this.resolver);
            return result == null ? null : result.toString();
        } else if (result instanceof BinaryOperatorExpression) {
            BinaryOperatorExpression expr = (BinaryOperatorExpression) result;
            result = expr.evaluate(this.resolver, this.mapper, null);
            return result.toString();
        } else if (result instanceof BooleanLiteral) {
            BooleanLiteral expr = (BooleanLiteral) result;
            result = expr.evaluate(this.resolver, this.mapper, null);
            return result.toString();
        } else {
            System.out.println("Incorrect type returned; not String, Expression or ExpressionString");
            return "";
        }
    } catch (ParseException pe) {
        throw new RuntimeException("ParseException thrown: " + pe.getMessage(), pe);
    } catch (ELException ele) {
        throw new RuntimeException("ELException thrown: " + ele.getMessage(), ele);
    }
}

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

/**
 * //ww  w . j a v a 2  s .c  o  m
 * Gets the parsed form of the given expression string. If the parsed form
 * is cached (and caching is not bypassed), return the cached form,
 * otherwise parse and cache the value. Returns either a String, Expression,
 * or ExpressionString.
 **/
public Object parseExpressionString(String pExpressionString) throws ELException {
    // See if it's an empty String
    if (pExpressionString.length() == 0) {
        return "";
    }

    // See if it's in the cache
    Object ret = null;

    if (ret == null) {
        // Parse the expression
        Reader r = new StringReader(pExpressionString);
        ELParser parser = new ELParser(r);
        try {
            ret = parser.ExpressionString();

        } catch (ParseException exc) {
            throw new ELException(exc);
        } catch (TokenMgrError exc) {
            // Note - this should never be reached, since the parser is
            // constructed to tokenize any input (illegal inputs get
            // parsed to <BADLY_ESCAPED_STRING_LITERAL> or
            // <ILLEGAL_CHARACTER>
            throw new ELException(exc.getMessage());
        }
    }
    return ret;
}