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

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

Introduction

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

Prototype

public static <T> T getValue(String expression, Object root, Class<T> resultType) throws OgnlException 

Source Link

Document

Convenience method that combines calls to parseExpression and getValue.

Usage

From source file:interactivespaces.expression.OgnlFilterExpression.java

@Override
public boolean accept(Object object) {
    try {/*from  w w w  .j  a va  2s  .  com*/
        Boolean value = Ognl.getValue(expression, context, object);
        return Boolean.TRUE.equals(value);
    } catch (OgnlException e) {
        throw new InteractiveSpacesException(String.format("Could not evaluate expression %s", expression), e);
    }
}

From source file:io.smartspaces.expression.OgnlFilterExpression.java

@Override
public boolean accept(Object object) {
    try {/*from   www. j  a  v  a2  s.  com*/
        Boolean value = Ognl.getValue(expression, context, object);
        return Boolean.TRUE.equals(value);
    } catch (OgnlException e) {
        throw new SmartSpacesException(String.format("Could not evaluate expression %s", expression), e);
    }
}

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./*from w w  w  . j  a va  2s.  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:interactivespaces.bridge.message.ros.OgnlRosMessageBridgeSpecification.java

/**
 * Execute the bridge.//from w  ww .  j ava2 s.c  o m
 *
 * @param source
 *          the source message to translate from
 * @param destination
 *          the destination message to translate to
 */
public void execute(SourceMessage source, DestinationMessage destination) {
    BridgeObject bo = new BridgeObject(source, destination);
    OgnlContext context = newContext();

    try {
        for (String expression : expressions) {
            Ognl.getValue(expression, context, bo);
        }
    } catch (OgnlException e) {
        throw new InteractiveSpacesException("Could not execute bridge expression", e);
    }
}

From source file:io.smartspaces.messaging.bridge.ros.OgnlRosMessageBridgeSpecification.java

@Override
public void execute(SourceMessage source, DestinationMessage destination) {
    BridgeObject bo = new BridgeObject(source, destination);
    OgnlContext context = newContext();//from   w w  w.j ava2s. c om

    try {
        for (String expression : expressions) {
            Ognl.getValue(expression, context, bo);
        }
    } catch (OgnlException e) {
        throw new SmartSpacesException("Could not execute bridge expression", e);
    }
}

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

public Object getValue(OgnlContext context, Object rootObject) throws OgnlException {
    return Ognl.getValue(getExpression(), context, rootObject);
}

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

public Object evaluate(OgnlContext ctx, OgnlRootObject rootObject) throws OgnlException {
    return Ognl.getValue(getExpression(), ctx, rootObject);
}