Example usage for org.apache.commons.ognl Ognl parseExpression

List of usage examples for org.apache.commons.ognl Ognl parseExpression

Introduction

In this page you can find the example usage for org.apache.commons.ognl Ognl parseExpression.

Prototype

public static Object parseExpression(String expression) throws OgnlException 

Source Link

Document

Parses the given OGNL expression and returns a tree representation of the expression that can be used by Ognl static methods.

Usage

From source file:it.d4nguard.rgrpg.util.dynacast.DynaManipulator.java

/**
 * Evaluates the given OGNL expression tree to extract a value from the
 * given root object.//w w  w  .j a  v  a 2  s  .c  o m
 * 
 * @see Ognl#parseExpression(String)
 * @param exp
 *            the OGNL expression to be parsed
 * @param root
 *            the root object for the OGNL expression
 * @return
 * @throws DynaManipulatorException
 */
public static Object getValue(String exp, Object root) throws DynaManipulatorException {
    assert root != null;
    Object ret = root;
    try {
        Object expression = Ognl.parseExpression(exp);
        Map<String, Object> context = Ognl.createDefaultContext(root, null, new AdapterTypeConverter());
        ret = Ognl.getValue(expression, context, root);
    } catch (Exception e) {
        throw new DynaManipulatorException(e);
    }
    return ret;
}

From source file:pl.nask.hsn2.expressions.OgnlExpression.java

public OgnlExpression(String expressionString) throws OgnlException {
    super();
    expression = Ognl.parseExpression(expressionString);
}