Package org.apache.commons.jexl.resolver

Examples of org.apache.commons.jexl.resolver.FlatResolver


      */
    public void testNotConditionsWithDots()
         throws Exception
    {
        Expression e = ExpressionFactory.createExpression("x.a");
        e.addPostResolver(new FlatResolver());
        JexlContext jc = JexlHelper.createContext();

        jc.getVars().put("x.a", Boolean.TRUE );
        jc.getVars().put("x.b", Boolean.FALSE );
        Object o = e.evaluate(jc);
View Full Code Here


         */

        Expression expr =
            ExpressionFactory.createExpression("foo.bar");

        expr.addPreResolver(new FlatResolver());

        JexlContext jc = JexlHelper.createContext();

        Foo foo = new Foo();

        jc.getVars().put("foo.bar", "flat value");
        jc.getVars().put("foo", foo );

        Object o = expr.evaluate(jc);

        assertEquals("flat override", o,"flat value");

        /*
         * now, let the resolver not find it and have it drop to jexl
         */

        expr =
            ExpressionFactory.createExpression("foo.bar.length()");

        expr.addPreResolver(new FlatResolver());

        o = expr.evaluate(jc);

        assertEquals("flat override 1", o,new Integer(GET_METHOD_STRING.length()));

        /*
         * now, let the resolver not find it and NOT drop to jexl
         */

        expr =
            ExpressionFactory.createExpression("foo.bar.length()");

        expr.addPreResolver(new FlatResolver(false));

        o = expr.evaluate(jc);

        assertEquals("flat override 2", o, null);

View Full Code Here

        /*
         * first, a simple override
         */

        Expression expr = ExpressionFactory.createExpression("foo.bar");
        expr.addPreResolver(new FlatResolver());

        JexlContext jc = JexlHelper.createContext();
        Foo foo = new Foo();
        jc.getVars().put("foo.bar", "flat value");
        jc.getVars().put("foo", foo );

        Object o = expr.evaluate(jc);
        assertEquals("flat override", "flat value", o);

        /*
         * now, let the resolver not find it and have it drop to jexl
         */
        expr = ExpressionFactory.createExpression("foo.bar.length()");
        expr.addPreResolver(new FlatResolver());
        o = expr.evaluate(jc);
        assertEquals("flat override 1", new Integer(GET_METHOD_STRING.length()), o);

        /*
         * now, let the resolver not find it and NOT drop to jexl
         */

        expr = ExpressionFactory.createExpression("foo.bar.length()");
        expr.addPreResolver(new FlatResolver(false));
        o = expr.evaluate(jc);
        assertEquals("flat override 2", o, null);
       
        // now for a post resolver
        expr = ExpressionFactory.createExpression("foo.bar.baz");
        Long result = new Long(1);
        jc.getVars().put("foo.bar.baz", result);
        expr.addPostResolver(new FlatResolver());
        assertEquals("flat override", result, expr.evaluate(jc));

    }
View Full Code Here

         */

        Expression expr =
            ExpressionFactory.createExpression("foo.bar");

        expr.addPreResolver(new FlatResolver());

        JexlContext jc = JexlHelper.createContext();

        Foo foo = new Foo();

        jc.getVars().put("foo.bar", "flat value");
        jc.getVars().put("foo", foo );

        Object o = expr.evaluate(jc);

        assertEquals("flat override", o,"flat value");

        /*
         * now, let the resolver not find it and have it drop to jexl
         */

        expr =
            ExpressionFactory.createExpression("foo.bar.length()");

        expr.addPreResolver(new FlatResolver());

        o = expr.evaluate(jc);

        assertEquals("flat override 1", o,new Integer(GET_METHOD_STRING.length()));

        /*
         * now, let the resolver not find it and NOT drop to jexl
         */

        expr =
            ExpressionFactory.createExpression("foo.bar.length()");

        expr.addPreResolver(new FlatResolver(false));

        o = expr.evaluate(jc);

        assertEquals("flat override 2", o, null);

View Full Code Here

TOP

Related Classes of org.apache.commons.jexl.resolver.FlatResolver

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.