Package org.apache.commons.jexl2

Examples of org.apache.commons.jexl2.Expression.evaluate()


            if (engine.getArithmetic() instanceof JexlThreadedArithmetic) {
                engine.setLenient(false);
            }
            engine.setSilent(false);
            Expression exp = engine.createExpression(expression);
            exp.evaluate(context);
            fail("expression: " + expression);
        } catch (JexlException xjexl) {
            if (matchException != null && !xjexl.getMessage().matches(matchException)) {
                fail("expression: " + expression + ", expected: " + matchException + ", got " + xjexl.getMessage());
            }
View Full Code Here


        if (expression != null && !expression.isEmpty() && jexlContext != null) {

            try {
                Expression jexlExpression = jexlEngine.createExpression(expression);
                Object evaluated = jexlExpression.evaluate(jexlContext);
                if (evaluated != null) {
                    result = evaluated.toString();
                }
            } catch (JexlException e) {
                LOG.error("Invalid jexl expression: " + expression, e);
View Full Code Here

            jc.set("sampleResult", previousResult); //$NON-NLS-1$ (may be null)
            jc.set("OUT", System.out);//$NON-NLS-1$

            // Now evaluate the script, getting the result
            Expression e = getJexlEngine().createExpression( exp );
            Object o = e.evaluate(jc);
            if (o != null)
            {
                str = o.toString();
            }
            if (vars != null && varName.length() > 0) {// vars will be null on TestPlan
View Full Code Here

        }
        Expression exp = null;
        try {
            final JexlContext effective = getEffectiveContext(jexlCtx);
            exp = getJexlEngine().createExpression(expr);
            return exp.evaluate(effective);
        } catch (Exception e) {
            String exMessage = e.getMessage() != null ? e.getMessage() : e.getClass().getCanonicalName();
            throw new SCXMLExpressionException("eval('" + expr + "'): " + exMessage, e);
        }
    }
View Full Code Here

        }
        Expression exp = null;
        try {
            final JexlContext effective = getEffectiveContext(jexlCtx);
            exp = getJexlEngine().createExpression(expr);
            return (Boolean) exp.evaluate(effective);
        } catch (Exception e) {
            String exMessage = e.getMessage() != null ? e.getMessage() : e.getClass().getCanonicalName();
            throw new SCXMLExpressionException("evalCond('" + expr + "'): " + exMessage, e);
        }
    }
View Full Code Here

        Expression exp = null;
        try {
            final JexlContext effective = getEffectiveContext(jexlCtx);
            effective.setEvaluatingLocation(true);
            exp = getJexlEngine().createExpression(expr);
            return (Node) exp.evaluate(effective);
        } catch (Exception e) {
            String exMessage = e.getMessage() != null ? e.getMessage() : e.getClass().getCanonicalName();
            throw new SCXMLExpressionException("evalLocation('" + expr + "'): " + exMessage, e);
        }
    }
View Full Code Here

                    // jexl to understand that is should do a string
                    // comparison
                    expression = replaceStrings(expression);
                    Expression e = evaluator.createExpression(expression);
                    try {
                        Object eval = e.evaluate(null);

                        Boolean result = false;
                        if (eval instanceof Boolean) {
                            result = (Boolean) eval;
                        } else if (eval instanceof String) {
View Full Code Here

        String result = StringUtils.EMPTY;

        if (StringUtils.isNotBlank(expression) && jexlContext != null) {
            try {
                Expression jexlExpression = getEngine().createExpression(expression);
                Object evaluated = jexlExpression.evaluate(jexlContext);
                if (evaluated != null) {
                    result = evaluated.toString();
                }
            } catch (JexlException e) {
                LOG.error("Invalid jexl expression: " + expression, e);
View Full Code Here

        Expression el = jexl.createExpression(expression);
        JexlContext elContext = new MapContext();
        for (String property : context.keySet()) {
            elContext.set(property, context.get(property));
        }
        return el.evaluate(elContext);
    }

    /**
     * If EL used inside code, the apostrophes around the ‘expression’ should be replaced with
     * the apostrophes like 'expression' to make it work.
View Full Code Here

        String result = subst.replace(var);

        try
        {
            Expression exp = engine.createExpression(result);
            result = (String) exp.evaluate(createContext());
        }
        catch (Exception e)
        {
            configuration.getLogger().debug("Error encountered evaluating " + result, e);
        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.