commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r589279 - in /commons/proper/jexl/branches/2.0/src: java/org/apache/commons/jexl/ test/org/apache/commons/jexl/
Date Sun, 28 Oct 2007 06:39:19 GMT
Author: dion
Date: Sat Oct 27 23:39:19 2007
New Revision: 589279

URL: http://svn.apache.org/viewvc?rev=589279&view=rev
Log:
JEXL-34 remove pre and post resolvers and JexlExprResolver class

Removed:
    commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/JexlExprResolver.java
Modified:
    commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/Expression.java
    commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/ExpressionImpl.java
    commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/JexlTest.java
    commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/ScriptFactoryTest.java

Modified: commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/Expression.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/Expression.java?rev=589279&r1=589278&r2=589279&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/Expression.java (original)
+++ commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/Expression.java Sat
Oct 27 23:39:19 2007
@@ -52,20 +52,4 @@
      */
     String getExpression();
 
-    /**
-     * Allows addition of a resolver to allow custom interdiction of
-     * expression evaluation.
-     *
-     * @param resolver resolver to be called before Jexl expression evaluated
-     */
-    void addPreResolver(JexlExprResolver resolver);
-
-    /**
-     * Allows addition of a resolver to allow custom interdiction of
-     * expression evaluation.
-     *
-     * @param resolver resolver to be called if Jexl expression
-     *  evaluated to null.
-     */
-    void addPostResolver(JexlExprResolver resolver);
 }

Modified: commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/ExpressionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/ExpressionImpl.java?rev=589279&r1=589278&r2=589279&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/ExpressionImpl.java
(original)
+++ commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/ExpressionImpl.java
Sat Oct 27 23:39:19 2007
@@ -17,7 +17,6 @@
 
 package org.apache.commons.jexl;
 
-import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.commons.jexl.parser.SimpleNode;
@@ -72,60 +71,7 @@
      * {@inheritDoc}
      */
     public Object evaluate(JexlContext context) throws Exception {
-        Object val = null;
-
-        /*
-         * if we have pre resolvers, give them a wack
-         */
-        if (preResolvers != null) {
-            val = tryResolver(preResolvers, context);
-
-            if (val != JexlExprResolver.NO_VALUE) {
-                return val;
-            }
-        }
-
-        val = interpreter.interpret(node, context);
-
-        /*
-         * if null, call post resolvers
-         */
-        if (val == null && postResolvers != null) {
-            val = tryResolver(postResolvers, context);
-
-            if (val != JexlExprResolver.NO_VALUE) {
-                return val;
-            }
-        }
-
-        return val;
-    }
-
-    /**
-     * Tries the resolvers in the given resolverlist against the context.
-     *
-     * @param resolverList list of JexlExprResolvers
-     * @param context JexlContext to use for evauluation
-     * @return value (including null) or JexlExprResolver.NO_VALUE
-     */
-    protected Object tryResolver(List resolverList, JexlContext context) {
-        Object val = JexlExprResolver.NO_VALUE;
-        String expr = getExpression();
-
-        for (int i = 0; i < resolverList.size(); i++) {
-            JexlExprResolver jer = (JexlExprResolver) resolverList.get(i);
-
-            val = jer.evaluate(context, expr);
-
-            /*
-             * as long as it's not NO_VALUE, return it
-             */
-            if (val != JexlExprResolver.NO_VALUE) {
-                return val;
-            }
-        }
-
-        return val;
+        return interpreter.interpret(node, context);
     }
 
     /**
@@ -133,26 +79,6 @@
      */
     public String getExpression() {
         return expression;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void addPreResolver(JexlExprResolver resolver) {
-        if (preResolvers == null) {
-            preResolvers = new ArrayList();
-        }
-        preResolvers.add(resolver);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void addPostResolver(JexlExprResolver resolver) {
-        if (postResolvers == null) {
-            postResolvers = new ArrayList();
-        }
-        postResolvers.add(resolver);
     }
 
     /**

Modified: commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/JexlTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/JexlTest.java?rev=589279&r1=589278&r2=589279&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/JexlTest.java (original)
+++ commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/JexlTest.java Sat Oct
27 23:39:19 2007
@@ -36,7 +36,6 @@
 
 import org.apache.commons.jexl.parser.ParseException;
 import org.apache.commons.jexl.parser.Parser;
-import org.apache.commons.jexl.resolver.FlatResolver;
 
 /**
  *  Simple testcases
@@ -773,50 +772,6 @@
         assertExpression(jc, "2 < '1'", Boolean.FALSE);
         assertExpression(jc, "2 <= '1'", Boolean.FALSE);
         assertExpression(jc, "2 <= '2'", Boolean.TRUE);
-}
-
-    public void testResolver()
-        throws Exception
-    {
-        /*
-         * 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));
-
     }
 
     /**

Modified: commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/ScriptFactoryTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/ScriptFactoryTest.java?rev=589279&r1=589278&r2=589279&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/ScriptFactoryTest.java
(original)
+++ commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/ScriptFactoryTest.java
Sat Oct 27 23:39:19 2007
@@ -98,7 +98,7 @@
      * @throws Exception on a parse error.
      */
     public void testCreateFromURL() throws Exception {
-        URL testUrl = new File("src/test-scripts/test1.jexl").toURL();
+        URL testUrl = new File("src/test-scripts/test1.jexl").toURI().toURL();
         assertNotNull("No script created", ScriptFactory.createScript(testUrl));
     }
 



Mime
View raw message