Package org.apache.commons.jexl2

Examples of org.apache.commons.jexl2.DebugInfo


        return null;
    }

    /** {@inheritDoc} */
    public String debugString() {
        DebugInfo info = debugInfo();
        return info != null ? info.debugString() : "";
    }
View Full Code Here


     * @param n the node
     * @throws ParseException
     */
    void jjtreeCloseNodeScope(JexlNode n) throws ParseException {
        if (n instanceof ASTAmbiguous && n.jjtGetNumChildren() > 0) {
            DebugInfo dbgInfo = null;
            Token tok = this.getToken(0);
            if (tok != null) {
                dbgInfo = new DebugInfo(tok.image, tok.beginLine, tok.beginColumn);
            } else {
                dbgInfo = n.debugInfo();
            }
            throw new JexlException.Parsing(dbgInfo, "Ambiguous statement, missing ';' between expressions", null);
        }
View Full Code Here

    }

    public Expression parse(String expressionString, int line, int column) throws ExpressionParsingException {
        org.apache.commons.jexl2.Expression compiledExpression;
        try {
            DebugInfo debug = new DebugInfo(expressionString, line, column);
            compiledExpression = engine.createExpression(expressionString, debug);
        } catch (JexlException e) {
            throw new ExpressionParsingException(line, column, expressionString, e);
        }
View Full Code Here

    public String evaluate(final String expression, final JexlContext jexlContext) {
        String result = "";

        if (StringUtils.isNotBlank(expression) && 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

     */
    @Override
    public FeatureState process(final ContextManager contextManager)
    {
        final JexlEngine jexlEngine = new JexlEngine();
        Expression jexlExpression;
        if (expression != null) {
            jexlExpression = jexlEngine.createExpression(expression);
        } else {
            jexlExpression = getOldExpression(jexlEngine);
        }
       
        final Map<String, Object> contextMap = contextManager.getContext(context);
        final JexlContext jexlContext = new MapContext(contextMap);

        return Boolean.TRUE.equals(jexlExpression.evaluate(jexlContext)) ? FeatureState.ENABLED : FeatureState.DISABLED;
    }
View Full Code Here

     * @param expected is the expected value of the expression
     * @throws Exception if the expression could not be evaluationed or an assertion
     * fails
     */
    public void assertExpression(String expression, Object expected) throws Exception {
        Expression exp = engine.createExpression(expression);
        Object value = exp.evaluate(context);

        assertEquals("expression: " + expression, expected, value);
    }
View Full Code Here

    public void failExpression(String expression, String matchException) throws Exception {
        boolean[] flags = { engine.isLenient(), engine.isSilent() };
        try {
            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

   
    /**
     * {@inheritDoc }
     */
    public Object evaluate(Object context, String expression) {
        Expression jexlExpression = engine.createExpression(expression);
        JexlContext jexlContext = new ObjectContext(engine, context);
       
        return jexlExpression.evaluate(jexlContext);
    }
View Full Code Here

    public Map<String, Object> getVariables() {
        return variables;
    }

    protected Expression createExpression(final String expression) throws Exception {
        Expression expr = engine.createExpression(expression);
        return expr;
    }
View Full Code Here

        if (expression == null) {
            throw new IllegalArgumentException("expression");
        }

        log.trace("Evaluating expression: {}", expression);
        Expression expr = createExpression(expression);
        Object obj = expr.evaluate(context);
        log.trace("Result: {}", obj);

        return obj;
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.jexl2.DebugInfo

Copyright © 2018 www.massapicom. 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.