commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r824684 - /commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/Main.java
Date Tue, 13 Oct 2009 10:52:17 GMT
Author: sebb
Date: Tue Oct 13 10:52:16 2009
New Revision: 824684

URL: http://svn.apache.org/viewvc?rev=824684&view=rev
Log:
Document expected behaviour when Exceptions occur.
Don't exit interactive session on ParseException.

Modified:
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/Main.java

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/Main.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/Main.java?rev=824684&r1=824683&r2=824684&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/Main.java (original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/Main.java Tue Oct 13 10:52:16
2009
@@ -22,21 +22,25 @@
 import java.io.InputStreamReader;
 
 import org.apache.commons.jexl.context.HashMapContext;
+import org.apache.commons.jexl.parser.ParseException;
 
 /**
- * Test application for Jexl
- * TODO - needs more options to be more useful.
+ * Test application for JEXL.
+ *
  * @since 2.0
  */
 public class Main {
     /**
-     * Test application for Jexl
+     * Test application for JEXL
      * 
      * If a single argument is present, it is treated as a filename of a JEXL
-     * script to be executed.
+     * script to be executed as a script. Any exceptions terminate the application.
+     * 
      * Otherwise, lines are read from standard input and evaluated.
+     * ParseExceptions and JexlExceptions are logged, and do not cause the application to
exit.
+     * This is done so that interactive testing is easier.
      * 
-     * @param args (optional) filename to evaluate. Stored in the args variable.
+     * @param args (optional) filename to execute. Stored in the args variable.
      * 
      * @throws Exception if parsing or IO fail
      */
@@ -57,10 +61,12 @@
                     Expression expression = engine.createExpression(line);
                     Object value = expression.evaluate(context);
                     System.out.println("Return value: " + value);
-                    System.out.print("> ");
+                } catch (ParseException e) {
+                    System.out.println(e.getLocalizedMessage());
                 } catch (JexlException e) {
                     System.out.println(e.getLocalizedMessage());
                 }
+                System.out.print("> ");
             }
         }
     }



Mime
View raw message