commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r587023 - /commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/Interpreter.java
Date Mon, 22 Oct 2007 07:51:15 GMT
Author: dion
Date: Mon Oct 22 00:51:14 2007
New Revision: 587023

URL: http://svn.apache.org/viewvc?rev=587023&view=rev
Log:
some checkstyle and code cleanup

Modified:
    commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/Interpreter.java

Modified: commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/Interpreter.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/Interpreter.java?rev=587023&r1=587022&r2=587023&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/Interpreter.java (original)
+++ commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/Interpreter.java Mon
Oct 22 00:51:14 2007
@@ -29,15 +29,16 @@
 import org.apache.commons.jexl.parser.ASTIntegerLiteral;
 import org.apache.commons.jexl.parser.ASTNullLiteral;
 import org.apache.commons.jexl.parser.ASTReference;
-import org.apache.commons.jexl.parser.ASTReferenceExpression;
-import org.apache.commons.jexl.parser.ParserTreeConstants;
 import org.apache.commons.jexl.parser.SimpleNode;
 import org.apache.commons.jexl.parser.VisitorAdapter;
 import org.apache.commons.jexl.util.Coercion;
 import org.apache.commons.jexl.util.Introspector;
 import org.apache.commons.jexl.util.introspection.Uberspect;
 
-
+/**
+ * Starting point for an interpreter of JEXL syntax.
+ * @author Dion Gillard
+ */
 class Interpreter extends VisitorAdapter {
 
     /** The uberspect. */
@@ -46,7 +47,7 @@
     /** The context to store/retrieve variables. */
     private JexlContext context;
     
-    /** the stack that holds values during expressions */
+    /** the stack that holds values during expressions. */
     private Stack valueStack;
 
     //private Resolver resolver;
@@ -59,6 +60,12 @@
         setUberspect(Introspector.getUberspect());
     }
 
+    /** 
+     * Interpret the given script/expression.
+     * @param node the script or expression to interpret.
+     * @param aContext the context to interpret against.
+     * @return the result of the interpretation.
+     */
     public Object interpret(SimpleNode node, JexlContext aContext) {
         setContext(aContext);
         valueStack = new Stack();
@@ -66,13 +73,19 @@
         return node.jjtAccept(this, null);
     }
 
-    public void setUberspect(Uberspect anUberspect)
-    {
+    /**
+     * sets the uberspect to use for divining bean properties etc.
+     * @param anUberspect the uberspect.
+     */
+    public void setUberspect(Uberspect anUberspect) {
         uberspect = anUberspect;
     }
 
-    protected Uberspect getUberspect()
-    {
+    /** 
+     * Gets the uberspect.
+     * @return an {@link Uberspect}
+     */
+    protected Uberspect getUberspect() {
         return uberspect;
     }
 
@@ -81,11 +94,8 @@
     }
 
     public Object visit(ASTBitwiseAndNode node, Object data) {
-        // evaluate left as long
-        Object left = ((SimpleNode) node.jjtGetChild(0)).jjtAccept(this, data);
-        // evaluate right as long
-        Object right = ((SimpleNode) node.jjtGetChild(1)).jjtAccept(this, data);
-        System.out.println("left is " + left + ", and right is " + right);
+        Object left = node.jjtGetChild(0).jjtAccept(this, data);
+        Object right = node.jjtGetChild(1).jjtAccept(this, data);
         // coerce these two values longs and add.
         long l = Coercion.coercelong(left);
         long r = Coercion.coercelong(right);



Mime
View raw message