commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hen...@apache.org
Subject svn commit: r1341050 [1/2] - in /commons/proper/jexl/trunk: ./ src/main/java/org/apache/commons/jexl3/ src/main/java/org/apache/commons/jexl3/annotations/ src/main/java/org/apache/commons/jexl3/internal/ src/main/java/org/apache/commons/jexl3/internal/...
Date Mon, 21 May 2012 14:39:24 GMT
Author: henrib
Date: Mon May 21 14:39:22 2012
New Revision: 1341050

URL: http://svn.apache.org/viewvc?rev=1341050&view=rev
Log:
JEXL-123:
Removed 'image' field from JexlNode - replaced by a 'name' for symbols - , reduced AST* method visibility wherever possible;
Better handling of constant literal nodes;
Moved 'sugar' method signatures (URL,File...) to API classes rather than core classes;
Building a Jxlt engine does not require importing 'internal' (duh);
Tweaked classloader handling by using a SoftReference;
Javadoc tweaks;
pom.xml tweaks

Added:
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/JavaccError.java   (with props)
Modified:
    commons/proper/jexl/trunk/pom.xml
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlEngine.java
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlException.java
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlExpression.java
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlInfo.java
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlScript.java
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/annotations/NoJexl.java
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/Debugger.java
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/Engine.java
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/Interpreter.java
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/Script.java
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/TemplateEngine.java
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/introspection/Introspector.java
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/introspection/Uberspect.java
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/package.html
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ASTArrayLiteral.java
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ASTIdentifier.java
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ASTIdentifierAccess.java
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ASTJexlLambda.java
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ASTMapLiteral.java
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ASTNumberLiteral.java
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ASTReferenceExpression.java
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ASTStringLiteral.java
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/JexlNode.java
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ParseException.java
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/StringParser.java
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/TokenMgrError.java
    commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ClassCreatorTest.java
    commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/IssuesTest.java
    commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/JexlEvalContext.java
    commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/JexlTest.java
    commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/SandboxTest.java
    commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/internal/Util.java
    commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/junit/Asserter.java

Modified: commons/proper/jexl/trunk/pom.xml
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/pom.xml?rev=1341050&r1=1341049&r2=1341050&view=diff
==============================================================================
--- commons/proper/jexl/trunk/pom.xml (original)
+++ commons/proper/jexl/trunk/pom.xml Mon May 21 14:39:22 2012
@@ -125,6 +125,12 @@
         <commons.release.2.binary.suffix />
         <commons.jira.id>JEXL</commons.jira.id>
         <commons.jira.pid>12310479</commons.jira.pid>
+        <!-- The plugins versions used by Jexl (in case they get defined in parent) -->
+        <commons.jexl.changes.version>2.7.1</commons.jexl.changes.version>
+        <commons.jexl.cobertura.version>2.5.1</commons.jexl.cobertura.version>
+        <commons.jexl.checkstyle.version>2.9.1</commons.jexl.checkstyle.version>
+        <commons.jexl.pmd.version>2.7.1</commons.jexl.pmd.version>
+        <commons.jexl.findbugs.version>2.4.0</commons.jexl.findbugs.version>
     </properties>
 
     <build>
@@ -172,20 +178,20 @@
                 </executions>
             </plugin>
             <plugin>
-              <groupId>org.apache.maven.plugins</groupId>
-              <artifactId>maven-jar-plugin</artifactId>
-              <executions>
-                <execution>
-                  <goals>
-                    <goal>test-jar</goal>
-                  </goals>
-                </execution>
-              </executions>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>test-jar</goal>
+                        </goals>
+                    </execution>
+                </executions>
             </plugin>
             <plugin>
                 <groupId>org.codehaus.mojo</groupId>
                 <artifactId>cobertura-maven-plugin</artifactId>
-                <version>2.5.1</version>
+                <version>${commons.jexl.cobertura.version}</version>
                 <configuration>
                     <instrumentation>
                         <ignores>
@@ -207,54 +213,54 @@
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-changes-plugin</artifactId>
-                <version>${commons.changes.version}</version>
+                <version>${commons.jexl.changes.version}</version>
                 <configuration>
                     <xmlPath>${basedir}/src/site/xdoc/changes.xml</xmlPath>
                     <issueLinkTemplatePerSystem>
                         <default>%URL%/%ISSUE%</default>
                     </issueLinkTemplatePerSystem>
                 </configuration>
-                <reportSets>
-                    <reportSet>
-                        <reports>
-                            <report>changes-report</report>
-                        </reports>
-                    </reportSet>
-                </reportSets>
             </plugin>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-checkstyle-plugin</artifactId>
-                <version>2.7</version>
+                <version>${commons.jexl.checkstyle.version}</version>
                 <configuration>
                     <configLocation>${basedir}/src/main/config/checkstyle.xml</configLocation>
                     <excludes>org/apache/commons/jexl3/parser/*.java</excludes>
                     <headerLocation>${basedir}/src/main/config/header.txt</headerLocation>
                     <enableRulesSummary>false</enableRulesSummary>
                 </configuration>
+                <reportSets>
+                    <reportSet>
+                        <reports>
+                            <report>checkstyle</report>
+                        </reports>
+                    </reportSet>
+                </reportSets>
             </plugin>
             <plugin>
                 <groupId>org.codehaus.mojo</groupId>
                 <artifactId>cobertura-maven-plugin</artifactId>
-                <version>2.5.1</version>
+                <version>${commons.jexl.cobertura.version}</version>
             </plugin>
             <plugin>
                 <groupId>org.codehaus.mojo</groupId>
                 <artifactId>findbugs-maven-plugin</artifactId>
-                <version>2.3.2</version>
+                <version>${commons.jexl.findbugs.version}</version>
                 <configuration>
                     <excludeFilterFile>${basedir}/src/main/config/findbugs-exclude-filter.xml</excludeFilterFile>
                     <xmlOutput>true</xmlOutput>
-                    <!-- Optional directory to put findbugs xdoc xml report -->
+                                <!-- Optional directory to put findbugs xdoc xml report -->
                     <xmlOutputDirectory>target/site</xmlOutputDirectory>
                 </configuration>
             </plugin>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-pmd-plugin</artifactId>
-                <version>2.6</version>
+                <version>${commons.jexl.pmd.version}</version>
                 <configuration>
-                    <targetJdk>1.5</targetJdk>
+                    <targetJdk>1.6</targetJdk>
                     <excludes>
                         <excludes>**/generated-sources/**/*</excludes>
                     </excludes>
@@ -274,8 +280,8 @@
                 <!-- version is defined in commons-parent -->
                 <configuration>
                     <excludes>
-                      <exclude>org/apache/commons/jexl3/parser/**</exclude>
-                      <exclude>org/apache/commons/jexl3/internal/**</exclude>
+                        <exclude>org/apache/commons/jexl3/parser/**</exclude>
+                        <exclude>org/apache/commons/jexl3/internal/**</exclude>
                     </excludes>
                 </configuration>
             </plugin>

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java?rev=1341050&r1=1341049&r2=1341050&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java (original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java Mon May 21 14:39:22 2012
@@ -366,6 +366,16 @@ public class JexlArithmetic {
 
     /**
      * Given an array of objects, attempt to type it more strictly.
+     * <p>This is a placeholder for derivation that calls the static typeArray method.</p>
+     * @param untyped an untyped array
+     * @return the original array if the attempt to strictly type the array fails, a typed array otherwise
+     */
+    public Object narrowArrayType(Object[] untyped) {
+        return typeArray(untyped);
+    }
+
+    /**
+     * Given an array of objects, attempt to type it more strictly.
      * <ul>
      * <li>If all objects are of the same type, the array returned will be an array of that same type</li>
      * <li>If all objects are Numbers, the array returned will be an array of Numbers</li>
@@ -375,7 +385,7 @@ public class JexlArithmetic {
      * @param untyped an untyped array
      * @return the original array if the attempt to strictly type the array fails, a typed array otherwise
      */
-    public Object narrowArrayType(Object[] untyped) {
+    public static Object typeArray(Object[] untyped) {
         final int size = untyped.length;
         Class<?> commonClass = null;
         if (size > 0) {

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlEngine.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlEngine.java?rev=1341050&r1=1341049&r2=1341050&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlEngine.java (original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlEngine.java Mon May 21 14:39:22 2012
@@ -81,6 +81,39 @@ public abstract class JexlEngine {
     }
 
     /**
+     * An empty/static/non-mutable JexlContext used instead of null context.
+     */
+    public static final JexlContext EMPTY_CONTEXT = new JexlContext() {
+        @Override
+        public Object get(String name) {
+            return null;
+        }
+
+        @Override
+        public boolean has(String name) {
+            return false;
+        }
+
+        @Override
+        public void set(String name, Object value) {
+            throw new UnsupportedOperationException("Not supported in void context.");
+        }
+    };
+
+    /**
+     * An empty/static/non-mutable JexlNamesapce used instead of null namespace.
+     */
+    public static final JexlContext.NamespaceResolver EMPTY_NS = new JexlContext.NamespaceResolver() {
+        @Override
+        public Object resolveNamespace(String name) {
+            return null;
+        }
+    };
+
+    /** The default Jxlt cache size. */
+    private static final int JXLT_CACHE_SIZE = 256;
+
+    /**
      * Gets this engine underlying {@link JexlUberspect}.
      * @return the uberspect
      */
@@ -122,7 +155,18 @@ public abstract class JexlEngine {
      * Creates a new {@link JxltEngine} instance using this engine.
      * @return a Jexl Template engine
      */
-    public abstract JxltEngine createJxltEngine();
+    public JxltEngine createJxltEngine() {
+        return createJxltEngine(JXLT_CACHE_SIZE, '$', '#');
+    }
+
+    /**
+     * Creates a new instance of {@link JxltEngine} using this engine.
+     * @param cacheSize the number of expressions in this cache, default is 256
+     * @param immediate the immediate template expression character, default is '$'
+     * @param deferred  the deferred template expression character, default is '#'
+     * @return a Jexl Template engine
+     */
+    public abstract JxltEngine createJxltEngine(int cacheSize, char immediate, char deferred);
 
     /**
      * Clears the expression cache.

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlException.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlException.java?rev=1341050&r1=1341049&r2=1341050&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlException.java (original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlException.java Mon May 21 14:39:22 2012
@@ -17,12 +17,14 @@
 package org.apache.commons.jexl3;
 
 import org.apache.commons.jexl3.internal.Debugger;
+import org.apache.commons.jexl3.parser.JavaccError;
 import org.apache.commons.jexl3.parser.JexlNode;
 import org.apache.commons.jexl3.parser.ParseException;
 import org.apache.commons.jexl3.parser.TokenMgrError;
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.UndeclaredThrowableException;
+
 import java.util.ArrayList;
 import java.util.List;
 
@@ -54,7 +56,14 @@ public class JexlException extends Runti
      * @param cause the exception causing the error
      */
     public JexlException(JexlNode node, String msg, Throwable cause) {
-        this(node != null ? node.jexlInfo() : null, msg != null ? msg : "", cause);
+        super(msg != null ? msg : "", unwrap(cause));
+        if (node != null) {
+            mark = node;
+            info = node.jexlInfo();
+        } else {
+            mark = null;
+            info = null;
+        }
     }
 
     /**
@@ -70,6 +79,14 @@ public class JexlException extends Runti
     }
 
     /**
+     * Gets the specific information for this exception.
+     * @return the information
+     */
+    public JexlInfo getInfo() {
+        return info;
+    }
+
+    /**
      * Cleans a JexlException from any org.apache.commons.jexl3.internal stack trace element.
      * @return this exception
      */
@@ -91,7 +108,7 @@ public class JexlException extends Runti
                 StackTraceElement se = stack[s];
                 String className = se.getClassName();
                 if (!className.startsWith("org.apache.commons.jexl3.internal")
-                    && !className.startsWith("org.apache.commons.jexl3.parser")) {
+                        && !className.startsWith("org.apache.commons.jexl3.parser")) {
                     stackJexl.add(se);
                 }
             }
@@ -116,6 +133,23 @@ public class JexlException extends Runti
     }
 
     /**
+     * Merge the node info and the cause info to obtain best possible location.
+     * @param info  the node
+     * @param cause the cause
+     * @return the info to use
+     */
+    private static JexlInfo merge(JexlInfo info, JavaccError cause) {
+        JexlInfo dbgn = info != null ? info : null;
+        if (cause == null) {
+            return dbgn;
+        } else if (dbgn == null) {
+            return new JexlInfo("", cause.getLine(), cause.getColumn());
+        } else {
+            return new JexlInfo(dbgn.getName(), cause.getLine(), cause.getColumn());
+        }
+    }
+
+    /**
      * Accesses detailed message.
      * @return the message
      */
@@ -161,24 +195,7 @@ public class JexlException extends Runti
         }
 
         /**
-         * Merge the node info and the cause info to obtain best possible location.
-         * @param info  the node
-         * @param cause the cause
-         * @return the info to use
-         */
-        private static JexlInfo merge(JexlInfo info, TokenMgrError cause) {
-            JexlInfo dbgn = info != null ? info : null;
-            if (cause == null) {
-                return dbgn;
-            } else if (dbgn == null) {
-                return new JexlInfo("", cause.getLine(), cause.getColumn());
-            } else {
-                return new JexlInfo(dbgn.getName(), cause.getLine(), cause.getColumn());
-            }
-        }
-
-        /**
-         * @return the last good token
+         * @return the specific detailed message
          */
         public String getDetail() {
             return super.detailedMessage();
@@ -214,24 +231,7 @@ public class JexlException extends Runti
         }
 
         /**
-         * Merge the node info and the cause info to obtain best possible location.
-         * @param info  the location information
-         * @param cause the cause
-         * @return the info to use
-         */
-        private static JexlInfo merge(JexlInfo info, ParseException cause) {
-            JexlInfo dbgn = info != null ? info : null;
-            if (cause == null) {
-                return dbgn;
-            } else if (dbgn == null) {
-                return new JexlInfo("", cause.getLine(), cause.getColumn());
-            } else {
-                return new JexlInfo(dbgn.getName(), cause.getLine(), cause.getColumn());
-            }
-        }
-
-        /**
-         * @return the last good token
+         * @return the specific detailed message
          */
         public String getDetail() {
             return super.detailedMessage();
@@ -387,28 +387,6 @@ public class JexlException extends Runti
     }
 
     /**
-     * Gets information about the cause of this error.
-     * <p>
-     * The returned string represents the outermost expression in error.
-     * The info parameter, an int[2] optionally provided by the caller, will be filled with the begin/end offset
-     * characters of the precise error's trigger.
-     * </p>
-     * @param offsets character offset interval of the precise node triggering the error
-     * @return a string representation of the offending expression, the empty string if it could not be determined
-     */
-    public String getInfo(int[] offsets) {
-        Debugger dbg = new Debugger();
-        if (dbg.debug(mark)) {
-            if (offsets != null && offsets.length >= 2) {
-                offsets[0] = dbg.start();
-                offsets[1] = dbg.end();
-            }
-            return dbg.toString();
-        }
-        return "";
-    }
-
-    /**
      * Detailed info message about this error.
      * Format is "debug![begin,end]: string \n msg" where:
      * - debug is the debugging information if it exists (@link JexlEngine.setDebug)
@@ -419,19 +397,23 @@ public class JexlException extends Runti
      */
     @Override
     public String getMessage() {
-        Debugger dbg = new Debugger();
         StringBuilder msg = new StringBuilder();
         if (info != null) {
             msg.append(info.toString());
+        } else {
+            msg.append('?');
         }
-        if (dbg.debug(mark)) {
-            msg.append("![");
-            msg.append(dbg.start());
-            msg.append(",");
-            msg.append(dbg.end());
-            msg.append("]: '");
-            msg.append(dbg.toString());
-            msg.append("'");
+        if (mark != null) {
+            Debugger dbg = new Debugger();
+            if (dbg.debug(mark)) {
+                msg.append("![");
+                msg.append(dbg.start());
+                msg.append(",");
+                msg.append(dbg.end());
+                msg.append("]: '");
+                msg.append(dbg.toString());
+                msg.append("'");
+            }
         }
         msg.append(' ');
         msg.append(detailedMessage());

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlExpression.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlExpression.java?rev=1341050&r1=1341049&r2=1341050&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlExpression.java (original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlExpression.java Mon May 21 14:39:22 2012
@@ -22,12 +22,12 @@ package org.apache.commons.jexl3;
  * Represents a single JEXL expression.
  * <p>
  * This simple interface provides access to the underlying textual expression through
- * {@link JexlExpression#getExpression()}.
+ * {@link JexlExpression#getSourceText()}.
  * </p>
  *
  * <p>
  * An expression is different than a script - it is simply a reference to
- * a single expression.
+ * a single expression, not to multiple statements.
  * </p>
  *
  * @since 1.0
@@ -44,14 +44,14 @@ public interface JexlExpression {
     Object evaluate(JexlContext context);
 
     /**
-     * Returns the JEXL expression this JexlExpression was created with.
-     * @return The JEXL expression to be evaluated
+     * Returns the source text of this expression.
+     * @return the source text
      */
-    CharSequence getParsedText();
+    String getSourceText();
 
     /**
-     * Returns the JEXL expression by reconstructing it from the parsed tree.
-     * @return the JEXL expression
+     * Recreates the source text of this expression from the internal synactic tree.
+     * @return the source text
      */
-    String dump();
+    String getParsedText();
 }

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlInfo.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlInfo.java?rev=1341050&r1=1341049&r2=1341050&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlInfo.java (original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlInfo.java Mon May 21 14:39:22 2012
@@ -31,12 +31,12 @@ public class JexlInfo {
 
     /**
      * Create info.
-     * @param tn template name
+     * @param source source name
      * @param l line number
      * @param c column number
      */
-    public JexlInfo(String tn, int l, int c) {
-        name = tn;
+    public JexlInfo(String source, int l, int c) {
+        name = source;
         line = l;
         column = c;
     }

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlScript.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlScript.java?rev=1341050&r1=1341049&r2=1341050&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlScript.java (original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlScript.java Mon May 21 14:39:22 2012
@@ -22,8 +22,7 @@ import java.util.concurrent.Callable;
 
 /**
  * <p>A JEXL Script.</p>
- * <p>A script is some valid JEXL syntax to be executed with
- * a given set of {@link JexlContext} variables.</p>
+ * <p>A script is some valid JEXL syntax to be executed with a given set of {@link JexlContext} variables.</p>
  * <p>A script is a group of statements, separated by semicolons.</p>
  * <p>The statements can be <code>blocks</code> (curly braces containing code),
  * Control statements such as <code>if</code> and <code>while</code>
@@ -56,12 +55,6 @@ public interface JexlScript extends Jexl
     Object execute(JexlContext context, Object... args);
 
     /**
-     * Returns the text of this Script.
-     * @return The script to be executed.
-     */
-    String getSourceText();
-
-    /**
      * Gets this script parameters.
      * @return the parameters or null
      * @since 2.1

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/annotations/NoJexl.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/annotations/NoJexl.java?rev=1341050&r1=1341049&r2=1341050&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/annotations/NoJexl.java (original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/annotations/NoJexl.java Mon May 21 14:39:22 2012
@@ -26,14 +26,14 @@ import java.lang.annotation.Target;
 /**
  * Indicates JEXL Introspection should not see this element.
  * <p>
- * This allows to completely hide a package, class, interface, constructor, method or field from 
+ * This allows to completely hide a package, class, interface, constructor, method or field from
  * JEXL; a NoJexl annotated element will not be usable through any kind of JEXL expression or script.
  * </p>
- * <p>See {@link org.apache.commons.jexl3.JexlSandbox} for another way to restrict JEXL access.
+ * See {@link org.apache.commons.jexl3.introspection.JexlSandbox} for another way to restrict JEXL access.
  */
 @Documented
 @Retention(RetentionPolicy.RUNTIME)
 @Target({ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.PACKAGE})
 public @interface NoJexl {
-    
+
 }

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/Debugger.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/Debugger.java?rev=1341050&r1=1341049&r2=1341050&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/Debugger.java (original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/Debugger.java Mon May 21 14:39:22 2012
@@ -487,10 +487,10 @@ public final class Debugger extends Pars
 
     @Override
     protected Object visit(ASTIdentifier node, Object data) {
-        String image = node.image;
+        String image = node.getName();
         if (QUOTED_IDENTIFIER.matcher(image).find() || NUMBER_IDENTIFIER.matcher(image).find()) {
             // quote it
-            image = "'" + node.image.replace("'", "\\'") + "'";
+            image = "'" + image.replace("'", "\\'") + "'";
         }
         return check(node, image, data);
     }
@@ -498,10 +498,10 @@ public final class Debugger extends Pars
     @Override
     protected Object visit(ASTIdentifierAccess node, Object data) {
         builder.append(".");
-        String image = node.image;
+        String image = node.getName();
         if (QUOTED_IDENTIFIER.matcher(image).find() || NUMBER_IDENTIFIER.matcher(image).find()) {
             // quote it
-            image = "'" + node.image.replace("'", "\\'") + "'";
+            image = "'" + image.replace("'", "\\'") + "'";
         }
         builder.append(image);
         return data;
@@ -526,7 +526,7 @@ public final class Debugger extends Pars
 
     @Override
     protected Object visit(ASTNumberLiteral node, Object data) {
-        return check(node, node.image, data);
+        return check(node, node.toString(), data);
     }
 
     @Override
@@ -750,7 +750,7 @@ public final class Debugger extends Pars
 
     @Override
     protected Object visit(ASTStringLiteral node, Object data) {
-        String img = node.image.replace("'", "\\'");
+        String img = node.getLiteral().replace("'", "\\'");
         return check(node, "'" + img + "'", data);
     }
 
@@ -784,7 +784,7 @@ public final class Debugger extends Pars
     @Override
     protected Object visit(ASTVar node, Object data) {
         builder.append("var ");
-        check(node, node.image, data);
+        check(node, node.getName(), data);
         return data;
     }
 

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/Engine.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/Engine.java?rev=1341050&r1=1341049&r2=1341050&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/Engine.java (original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/Engine.java Mon May 21 14:39:22 2012
@@ -60,35 +60,6 @@ import java.lang.ref.SoftReference;
  */
 public class Engine extends JexlEngine {
     /**
-     * An empty/static/non-mutable JexlContext used instead of null context.
-     */
-    public static final JexlContext EMPTY_CONTEXT = new JexlContext() {
-        @Override
-        public Object get(String name) {
-            return null;
-        }
-
-        @Override
-        public boolean has(String name) {
-            return false;
-        }
-
-        @Override
-        public void set(String name, Object value) {
-            throw new UnsupportedOperationException("Not supported in void context.");
-        }
-    };
-    /**
-     * An empty/static/non-mutable JexlNamesapce used instead of null namespace.
-     */
-    public static final JexlContext.NamespaceResolver EMPTY_NS = new JexlContext.NamespaceResolver() {
-        @Override
-        public Object resolveNamespace(String name) {
-            return null;
-        }
-    };
-
-    /**
      * Gets the default instance of Uberspect.
      * <p>This is lazily initialized to avoid building a default instance if there
      * is no use for it. The main reason for not using the default Uberspect instance is to
@@ -211,11 +182,6 @@ public class Engine extends JexlEngine {
     }
 
     @Override
-    public TemplateEngine createJxltEngine() {
-        return new TemplateEngine(this);
-    }
-
-    @Override
     public boolean isDebug() {
         return this.debug;
     }
@@ -235,6 +201,11 @@ public class Engine extends JexlEngine {
         uberspect.setClassLoader(loader);
     }
 
+    @Override
+    public TemplateEngine createJxltEngine(int cacheSize, char immediate, char deferred) {
+        return new TemplateEngine(this, cacheSize, immediate, deferred);
+    }
+
     /**
      * A soft referenced cache.
      * <p>The actual cache is held through a soft reference, allowing it to be GCed under
@@ -549,7 +520,7 @@ public class Engine extends JexlEngine {
                     ref = new ArrayList<String>();
                     refs.add(ref);
                 }
-                ref.add(identifier.image);
+                ref.add(identifier.getName());
             }
         } else {
             int num = node.jjtGetNumChildren();
@@ -562,16 +533,17 @@ public class Engine extends JexlEngine {
                     JexlNode child = node.jjtGetChild(i);
                     if (array) {
                         if (varf && child.isConstant()) {
-                            String image = child.image;
+                            String image = child.toString();
                             if (image == null) {
                                 var.add(new Debugger().data(child));
                             } else {
                                 var.add(image);
                             }
                         } else if (child instanceof ASTIdentifier) {
-                            if (((ASTIdentifier) child).getSymbol() < 0) {
+                            ASTIdentifier ichild = (ASTIdentifier) child;
+                            if (ichild.getSymbol() < 0) {
                                 List<String> di = new ArrayList<String>(1);
-                                di.add(child.image);
+                                di.add(ichild.getName());
                                 refs.add(di);
                             }
                             var = new ArrayList<String>();
@@ -579,13 +551,14 @@ public class Engine extends JexlEngine {
                         }
                         continue;
                     } else if (child instanceof ASTIdentifier) {
-                        if (i == 0 && (((ASTIdentifier) child).getSymbol() < 0)) {
-                            var.add(child.image);
+                        ASTIdentifier ichild = (ASTIdentifier) child;
+                        if (i == 0 && ichild.getSymbol() < 0) {
+                            var.add(ichild.getName());
                         }
                         varf = false;
                         continue;
                     } else if (child instanceof ASTIdentifierAccess) {
-                        var.add(child.image);
+                        var.add(((ASTIdentifierAccess) child).getName());
                         varf = false;
                         continue;
                     }

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/Interpreter.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/Interpreter.java?rev=1341050&r1=1341049&r2=1341050&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/Interpreter.java (original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/Interpreter.java Mon May 21 14:39:22 2012
@@ -331,7 +331,6 @@ public class Interpreter extends ParserV
                 array[i] = entry;
             }
             literal = arithmetic.narrowArrayType(array);
-            node.setLiteral(literal);
         }
         return literal;
     }
@@ -466,7 +465,7 @@ public class Interpreter extends ParserV
                     // set loopVariable to value of iterator
                     Object value = itemsIterator.next();
                     if (symbol < 0) {
-                        context.set(loopVariable.image, value);
+                        context.set(loopVariable.getName(), value);
                     } else {
                         frame.set(symbol, value);
                     }
@@ -777,7 +776,7 @@ public class Interpreter extends ParserV
         if (data != null) {
             return getAttribute(data, node.getLiteral(), node);
         }
-        return node.image;
+        return node.getLiteral();
     }
 
     @Override
@@ -963,7 +962,7 @@ public class Interpreter extends ParserV
         if (isCancelled()) {
             throw new JexlException.Cancel(node);
         }
-        String name = node.image;
+        String name = node.getName();
         if (data == null) {
             int symbol = node.getSymbol();
             if (symbol >= 0) {
@@ -1067,7 +1066,7 @@ public class Interpreter extends ParserV
                 if (v == 0) {
                     // first node must be an Identifier
                     if (objectNode instanceof ASTIdentifier) {
-                        variableName = new StringBuilder(objectNode.image);
+                        variableName = new StringBuilder(((ASTIdentifier) objectNode).getName());
                         v = 1;
                     } else {
                         break main;
@@ -1078,7 +1077,7 @@ public class Interpreter extends ParserV
                     objectNode = node.jjtGetChild(v);
                     if (objectNode instanceof ASTIdentifierAccess) {
                         variableName.append('.');
-                        variableName.append(objectNode.image);
+                        variableName.append(((ASTIdentifierAccess) objectNode).getName());
                     } else {
                         break main;
                     }
@@ -1120,13 +1119,13 @@ public class Interpreter extends ParserV
                 // check we are not assigning direct global
                 if (last < 0) {
                     try {
-                        context.set(var.image, right);
+                        context.set(var.getName(), right);
                     } catch (UnsupportedOperationException xsupport) {
                         throw new JexlException(node, "context is readonly", xsupport);
                     }
                     return right;
                 }
-                object = context.get(var.image);
+                object = context.get(var.getName());
             }
         } else if (!(left instanceof ASTReference)) {
             throw new JexlException(left, "illegal assignment form 0");
@@ -1152,7 +1151,7 @@ public class Interpreter extends ParserV
             if (isVariable) {
                 if (v == 0) {
                     if (objectNode instanceof ASTIdentifier) {
-                        variableName = new StringBuilder(objectNode.image);
+                        variableName = new StringBuilder(((ASTIdentifier) objectNode).getName());
                         v = 1;
                     } else {
                         isVariable = false;
@@ -1162,7 +1161,7 @@ public class Interpreter extends ParserV
                     JexlNode child = left.jjtGetChild(v);
                     if (child instanceof ASTIdentifierAccess) {
                         variableName.append('.');
-                        variableName.append(child.image);
+                        variableName.append(((ASTIdentifierAccess) objectNode).getName());
                     } else {
                         isVariable = false;
                     }
@@ -1290,11 +1289,11 @@ public class Interpreter extends ParserV
             ASTIdentifier methodIdentifier = (ASTIdentifier) functor;
             symbol = methodIdentifier.getSymbol();
             if (symbol < 0) {
-                methodName = methodIdentifier.image;
+                methodName = methodIdentifier.getName();
             }
             functor = null;
         } else if (functor instanceof ASTIdentifierAccess) {
-            methodName = ((ASTIdentifierAccess) functor).image;
+            methodName = ((ASTIdentifierAccess) functor).getName();
             functor = null;
         }
         try {
@@ -1379,7 +1378,7 @@ public class Interpreter extends ParserV
             return call(node, namespace, functionNode, argNode);
         } else {
             // objectNode 0 is the prefix
-            String prefix = node.jjtGetChild(0).image;
+            String prefix = ((ASTIdentifier) node.jjtGetChild(0)).getName();
             Object namespace = resolveNamespace(prefix, node);
             // objectNode 1 is the identifier , the others are parameters.
             ASTIdentifier functionNode = (ASTIdentifier) node.jjtGetChild(1);

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/Script.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/Script.java?rev=1341050&r1=1341049&r2=1341050&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/Script.java (original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/Script.java Mon May 21 14:39:22 2012
@@ -87,13 +87,6 @@ public class Script implements JexlScrip
         return interpreter.interpret(script.jjtGetChild(0));
     }
 
-    @Override
-    public String dump() {
-        Debugger debug = new Debugger();
-        boolean d = debug.debug(script);
-        return debug.toString() + (d ? " /*" + debug.start() + ":" + debug.end() + "*/" : "/*?:?*/ ");
-    }
-
     /**
      * Gets this script original script source.
      * @return the contents of the input source as a String.

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/TemplateEngine.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/TemplateEngine.java?rev=1341050&r1=1341049&r2=1341050&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/TemplateEngine.java (original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/TemplateEngine.java Mon May 21 14:39:22 2012
@@ -47,34 +47,15 @@ public final class TemplateEngine extend
     private final Engine jexl;
     /** The TemplateExpression cache. */
     private final Engine.SoftCache<String, TemplateExpression> cache;
-    /** The default cache size. */
-    private static final int CACHE_SIZE = 256;
     /** The first character for immediate expressions. */
     private final char immediateChar;
     /** The first character for deferred expressions. */
     private final char deferredChar;
 
     /**
-     * Creates a new instance of {@link JxltEngine} with a default cache size.
-     * @param aJexl the JexlEngine to use.
-     */
-    public TemplateEngine(Engine aJexl) {
-        this(aJexl, CACHE_SIZE);
-    }
-
-    /**
-     * Creates a new instance of {@link JxltEngine} creating a local cache.
-     * @param aJexl     the JexlEngine to use.
-     * @param cacheSize the number of expressions in this cache
-     */
-    public TemplateEngine(Engine aJexl, int cacheSize) {
-        this(aJexl, cacheSize, '$', '#');
-    }
-
-    /**
      * Creates a new instance of {@link JxltEngine} creating a local cache.
      * @param aJexl     the JexlEngine to use.
-     * @param cacheSize the number of expressions in this cache
+     * @param cacheSize the number of expressions in this cache, default is 256
      * @param immediate the immediate template expression character, default is '$'
      * @param deferred  the deferred template expression character, default is '#'
      */

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/introspection/Introspector.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/introspection/Introspector.java?rev=1341050&r1=1341049&r2=1341050&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/introspection/Introspector.java (original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/introspection/Introspector.java Mon May 21 14:39:22 2012
@@ -63,10 +63,13 @@ public final class Introspector {
         public CacheMiss() {
         }
     }
-    /** The cache-miss marker for the constructors map. */
+    /**
+     * The cache-miss marker for the constructors map.
+     */
     private static final Constructor<?> CTOR_MISS = CacheMiss.class.getConstructors()[0];
-
-    /** the logger. */
+    /**
+     * the logger.
+     */
     protected final Log rlog;
     /**
      * The class loader used to solve constructors if needed.
@@ -91,7 +94,7 @@ public final class Introspector {
 
     /**
      * Create the introspector.
-     * @param log the logger to use
+     * @param log     the logger to use
      * @param cloader the class loader
      */
     public Introspector(Log log, ClassLoader cloader) {
@@ -114,8 +117,8 @@ public final class Introspector {
 
     /**
      * Gets a method defined by a class, a name and a set of parameters.
-     * @param c the class
-     * @param name the method name
+     * @param c      the class
+     * @param name   the method name
      * @param params the method parameters
      * @return the desired method object
      * @throws MethodKey.AmbiguousException if no unambiguous method could be found through introspection
@@ -127,8 +130,8 @@ public final class Introspector {
     /**
      * Gets the method defined by the <code>MethodKey</code> for the class <code>c</code>.
      *
-     * @param c     Class in which the method search is taking place
-     * @param key   Key of the method being searched for
+     * @param c   Class in which the method search is taking place
+     * @param key Key of the method being searched for
      * @return The desired method object
      * @throws MethodKey.AmbiguousException if no unambiguous method could be found through introspection
      */
@@ -149,8 +152,8 @@ public final class Introspector {
     /**
      * Gets the field named by <code>key</code> for the class <code>c</code>.
      *
-     * @param c     Class in which the field search is taking place
-     * @param key   Name of the field being searched for
+     * @param c   Class in which the field search is taking place
+     * @param key Name of the field being searched for
      * @return the desired field or null if it does not exist or is not accessible
      * */
     public Field getField(Class<?> c, String key) {
@@ -185,7 +188,7 @@ public final class Introspector {
 
     /**
      * Gets the array of accessible method known for a given class.
-     * @param c the class
+     * @param c          the class
      * @param methodName the method name
      * @return the array of methods (null or not empty)
      */
@@ -200,7 +203,7 @@ public final class Introspector {
     /**
      * Gets the constructor defined by the <code>MethodKey</code>.
      *
-     * @param key   Key of the constructor being searched for
+     * @param key Key of the constructor being searched for
      * @return The desired constructor object
      * or null if no unambiguous constructor could be found through introspection.
      */
@@ -210,8 +213,8 @@ public final class Introspector {
 
     /**
      * Gets the constructor defined by the <code>MethodKey</code>.
-     * @param c the class we want to instantiate
-     * @param key   Key of the constructor being searched for
+     * @param c   the class we want to instantiate
+     * @param key Key of the constructor being searched for
      * @return The desired constructor object
      * or null if no unambiguous constructor could be found through introspection.
      */
@@ -303,11 +306,8 @@ public final class Introspector {
                 // try again
                 classMap = classMethodMaps.get(c);
                 if (classMap == null) {
-                    classMap = classMethodMaps.get(c);
-                    if (classMap == null) {
-                        classMap = new ClassMap(c, rlog);
-                        classMethodMaps.put(c, classMap);
-                    }
+                    classMap = new ClassMap(c, rlog);
+                    classMethodMaps.put(c, classMap);
                 }
             } finally {
                 lock.writeLock().unlock();
@@ -328,38 +328,47 @@ public final class Introspector {
             cloader = getClass().getClassLoader();
         }
         if (!cloader.equals(loader)) {
-            // clean up constructor and class maps
-            synchronized (constructorsMap) {
-                Iterator<Map.Entry<MethodKey, Constructor<?>>> entries = constructorsMap.entrySet().iterator();
-                while (entries.hasNext()) {
-                    Map.Entry<MethodKey, Constructor<?>> entry = entries.next();
+            try {
+                lock.writeLock().lock();
+                // clean up constructor and class maps
+                Iterator<Map.Entry<MethodKey, Constructor<?>>> mentries = constructorsMap.entrySet().iterator();
+                while (mentries.hasNext()) {
+                    Map.Entry<MethodKey, Constructor<?>> entry = mentries.next();
                     Class<?> clazz = entry.getValue().getDeclaringClass();
                     if (isLoadedBy(previous, clazz)) {
-                        entries.remove();
+                        mentries.remove();
                         // the method name is the name of the class
                         constructibleClasses.remove(entry.getKey().getMethod());
                     }
                 }
-            }
-            // clean up method maps
-            synchronized (classMethodMaps) {
-                Iterator<Map.Entry<Class<?>, ClassMap>> entries = classMethodMaps.entrySet().iterator();
-                while (entries.hasNext()) {
-                    Map.Entry<Class<?>, ClassMap> entry = entries.next();
+                // clean up method maps
+                Iterator<Map.Entry<Class<?>, ClassMap>> centries = classMethodMaps.entrySet().iterator();
+                while (centries.hasNext()) {
+                    Map.Entry<Class<?>, ClassMap> entry = centries.next();
                     Class<?> clazz = entry.getKey();
                     if (isLoadedBy(previous, clazz)) {
-                        entries.remove();
+                        centries.remove();
                     }
                 }
+                loader = cloader;
+            } finally {
+                lock.writeLock().unlock();
             }
-            loader = cloader;
         }
     }
 
     /**
+     * Gets the class loader used by this introspector.
+     * @return the class loader
+     */
+    public ClassLoader getLoader() {
+        return loader;
+    }
+
+    /**
      * Checks whether a class is loaded through a given class loader or one of its ascendants.
      * @param loader the class loader
-     * @param clazz the class to check
+     * @param clazz  the class to check
      * @return true if clazz was loaded through the loader, false otherwise
      */
     private static boolean isLoadedBy(ClassLoader loader, Class<?> clazz) {

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/introspection/Uberspect.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/introspection/Uberspect.java?rev=1341050&r1=1341049&r2=1341050&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/introspection/Uberspect.java (original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/introspection/Uberspect.java Mon May 21 14:39:22 2012
@@ -18,7 +18,6 @@ package org.apache.commons.jexl3.interna
 
 import java.lang.ref.Reference;
 import java.lang.ref.SoftReference;
-import java.lang.ref.WeakReference;
 import java.lang.reflect.Field;
 
 import java.lang.reflect.Method;
@@ -51,8 +50,8 @@ public class Uberspect implements JexlUb
     private volatile Reference<Introspector> ref;
     /** The introspector version. */
     private volatile int version;
-    /** The class loader weak reference; used to recreate the Introspector when necessary. */
-    private volatile Reference<ClassLoader> loader = null;
+    /** The class loader reference; used to recreate the Introspector when necessary. */
+    private volatile Reference<ClassLoader> loader;
 
     /**
      * Creates a new Uberspect.
@@ -61,8 +60,8 @@ public class Uberspect implements JexlUb
     public Uberspect(Log runtimeLogger) {
         rlog = runtimeLogger;
         ref = new SoftReference<Introspector>(null);
+        loader = new SoftReference<ClassLoader>(getClass().getClassLoader());
         version = 0;
-        loader = new WeakReference<ClassLoader>(getClass().getClassLoader());
     }
 
     /**
@@ -78,14 +77,9 @@ public class Uberspect implements JexlUb
             synchronized (this) {
                 intro = ref.get();
                 if (intro == null) {
-                    ClassLoader cloader = loader.get();
-                    if (cloader == null) {
-                        // that would be really odd though...
-                        cloader = getClass().getClassLoader();
-                        loader = new WeakReference<ClassLoader>(cloader);
-                    }
-                    intro = new Introspector(rlog, cloader);
+                    intro = new Introspector(rlog, loader.get());
                     ref = new SoftReference<Introspector>(intro);
+                    loader = new SoftReference<ClassLoader>(intro.getLoader());
                     version += 1;
                 }
             }
@@ -97,22 +91,23 @@ public class Uberspect implements JexlUb
     @Override
     public void setClassLoader(ClassLoader nloader) {
         synchronized (this) {
-            if (nloader == null) {
-                nloader = getClass().getClassLoader();
-            }
-            ClassLoader cloader = loader.get();
-            if (!nloader.equals(cloader)) {
-                Introspector intro = new Introspector(rlog, nloader);
-                loader = new WeakReference<ClassLoader>(nloader);
+            Introspector intro = ref.get();
+            if (intro != null) {
+                intro.setLoader(nloader);
+            } else {
+                intro = new Introspector(rlog, nloader);
                 ref = new SoftReference<Introspector>(intro);
-                version += 1;
             }
+            loader = new SoftReference<ClassLoader>(intro.getLoader());
+            version += 1;
         }
     }
 
     @Override
     public int getVersion() {
-        return version;
+        synchronized(this) {
+            return version;
+        }
     }
 
     /**

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/package.html
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/package.html?rev=1341050&r1=1341049&r2=1341050&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/package.html (original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/package.html Mon May 21 14:39:22 2012
@@ -52,7 +52,7 @@
         </p>
         <pre>
             // Create a JexlEngine (could reuse one instead)
-            JexlEngine jexl = new JexlEngine();
+            JexlEngine jexl = new JexlBuilder().create();
             // Create an expression object equivalent to 'car.getEngine().checkStatus()':
             String jexlExp = "car.engine.checkStatus()";
             Expression e = jexl.createExpression( jexlExp );
@@ -75,8 +75,7 @@
         </ul>
 
         <h3><a name="usage_note">Important note</a></h3>
-        The public API classes start with 'Jexl*' or 'Jxl*'.
-        The only public packages you should use are:
+        The public API classes reside in the 2 packages:
         <ul>
             <li>org.apache.commons.jexl3</li>
             <li>org.apache.commons.jexl3.introspection</li>
@@ -129,7 +128,7 @@
                 public void setStr(String str) { this.str = str; }
             }
             // test API
-            JexlEngine jexl = nex JexlEngine();
+            JexlEngine jexl = new JexlBuilder().create();
             Quux quux = jexl.newInstance(Quux.class, "xuuq", 100);
             jexl.setProperty(quux, "froboz.value", Integer.valueOf(100));
             Object o = jexl.getProperty(quux, "froboz.value");
@@ -153,7 +152,7 @@
         </ul>
         The following example illustrates their usage:
         <pre>
-            JexlEngine jexl = nex JexlEngine();
+            JexlEngine jexl = new JexlBuilder().create();
 
             JexlContext jc = new MapContext();
             jc.set("quuxClass", quux.class);
@@ -184,7 +183,7 @@
         </ul>
         The following example illustrates their usage:
         <pre>
-            JexlEngine jexl = new JexlEngine();
+            JexlEngine jexl = new JexlBuilder().create();
             JxltEngine jxlt = jexl.jxlt();
             JxltEngine.UnifiedExpression expr = jxlt.createExpression("Hello ${user}");
             String hello = jxlt.evaluate(context, jxlt).toString();
@@ -245,16 +244,20 @@
             in case of errors.
             These configuration methods are embedded through a {@link org.apache.commons.jexl3.JexlBuilder}.
         </p>
-        <h3><a name="static_configuration">Static Configuration</a></h3>
+        <h3><a name="static_configuration">Static &amp; Shared Configuration</a></h3>
         <p>
-            Both JexlEngine and JxltEngine are thread-safe, all their inner fields are final; the same instance can be shared between different
+            Both JexlEngine and JxltEngine are thread-safe, most of their inner fields are final; the same instance can be shared between different
             threads and proper synchronization is enforced in critical areas (introspection caches).
-            The following properties can only be set during JexlEngine creation.
         </p>
         <p>
-            {@link org.apache.commons.jexl3.JexlBuilder#loader} indicates to the JexlEngine being built which class loader
-            to use to solve a class name; this affects how JexlEngine.newInstance and the 'new' script method operates.
-            This is mostly useful in cases where you rely on JEXL to dynamically load and call plugins for your application.
+            Of particular importance is {@link org.apache.commons.jexl3.JexlBuilder#loader} which indicates to the JexlEngine
+            being built which class loader to use to solve a class name; this directly affects how JexlEngine.newInstance and the 'new' script method operates.
+        </p>
+        <p>
+            This can also be very useful in cases where you rely on JEXL to dynamically load and call plugins for your application.
+            To avoid having to restart the server in case of a plugin implementation change, you can call
+            {@link org.apache.commons.jexl3.JexlEngine#setClassLoader} and all the scripts created through this engine instance
+            will automatically point to the newly loaded classes.
         </p>
         <p>
             You can state what can be manipulated through scripting by the {@link org.apache.commons.jexl3.annotations.NoJexl}
@@ -294,11 +297,11 @@
             JexlEngine and JxltEngine expression caches can be configured as well. If you intend to use JEXL
             repeatedly in your application, these are worth configuring since expression parsing is quite heavy.
             Note that all caches created by JEXL are held through SoftReference; under high memory pressure, the GC will be able
-            to reclaim those caches and JEXL will rebuild them if needed. By default, a JexlEngine does not create a cache
-            whilst JxltEngine does.
+            to reclaim those caches and JEXL will rebuild them if needed. By default, a JexlEngine does create a cache for "small" expressions
+            and a JxltEngine does create one for UnifiedExpression .
         </p>
         <p>{@link org.apache.commons.jexl3.JexlBuilder#cache} will set how many expressions can be simultaneously cached by the
-            JEXL engine. UnifiedJEXL allows to define the cache size through its constructor.
+            JEXL engine. JxltEngine allows to define the cache size through its constructor.
         </p>
         <p>
             {@link org.apache.commons.jexl3.JexlBuilder#debug}
@@ -308,25 +311,26 @@
 
         <h3><a name="dynamic_configuration">Dynamic Configuration</a></h3>
         <p>
-            Those configuration options can be overriden during evaluation by using a {@link org.apache.commons.jexl3.JexlEvalContext}
-            which merges both a {@link org.apache.commons.jexl3.JexlContext} to expose variables and a
-            {@link org.apache.commons.jexl3.JexlEngine$Options} to carry evaluation options.
+            Those configuration options can be overriden during evaluation by implementing a {@link org.apache.commons.jexl3.JexlContext}
+            that also implements {@link org.apache.commons.jexl3.JexlEngine$Options} to carry evaluation options.
+            An example of such a class exists in the test package.
         </p>
         <p>
-            {@link org.apache.commons.jexl3.JexlBuilder#strict} or {@link org.apache.commons.jexl3.JexlEvalContext#setStrict}
+            {@link org.apache.commons.jexl3.JexlBuilder#strict} or {@link org.apache.commons.jexl3.JexlEngine$Options#isStrict}
             configures when JEXL considers 'null' as an error or not in various situations;
             when facing an unreferenceable variable, using null as an argument to an arithmetic operator or failing to call
             a method or constructor. The lenient mode is close to JEXL-1.1 behavior.
         </p>
         <p>
-            {@link org.apache.commons.jexl3.JexlBuilder#silent} or {@link org.apache.commons.jexl3.JexlEvalContext#setSilent}
+            {@link org.apache.commons.jexl3.JexlBuilder#silent} or {@link org.apache.commons.jexl3.JexlEngine$Options#isSilent}
             configures how JEXL reacts to errors; if silent, the engine will not throw exceptions
             but will warn through loggers and return null in case of errors. Note that when non-silent, JEXL throws
             JexlException which are unchecked exception.
         </p>
         <p>
-            Implementing a {@link org.apache.commons.jexl3.JexlContext$NamespaceResolver} through a JexlContext - by deriving
-            JexlEvalContext for instance - allows to override the namespace resolution and the default namespace map defined
+            Implementing a {@link org.apache.commons.jexl3.JexlContext$NamespaceResolver} through a JexlContext - look at
+            <a href="http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/org/apache/commons/jexl3/JexlEvalContext.java?view=markup">JexlEvalContext</a>
+            as an example - allows to override the namespace resolution and the default namespace map defined
             through {@link org.apache.commons.jexl3.JexlBuilder#namespaces}.
         </p>
 
@@ -336,7 +340,7 @@
             The {@link org.apache.commons.jexl3.JexlContext}, {@link org.apache.commons.jexl3.JexlBuilder} and
             {@link org.apache.commons.jexl3.JexlEngine$Options} are
             the most likely interfaces you'll want to implement for customization. Since they expose variables and options,
-            they are the primary targets. Before you do so, have a look at {@link org.apache.commons.jexl3.JexlEvalContext}
+            they are the primary targets. Before you do so, have a look at JexlEvalContext in the test directory
             and {@link org.apache.commons.jexl3.ObjectContext} which may already cover some of your needs.
         </p>
         <p>

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ASTArrayLiteral.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ASTArrayLiteral.java?rev=1341050&r1=1341049&r2=1341050&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ASTArrayLiteral.java (original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ASTArrayLiteral.java Mon May 21 14:39:22 2012
@@ -16,11 +16,14 @@
  */
 package org.apache.commons.jexl3.parser;
 
+import org.apache.commons.jexl3.JexlArithmetic;
+import org.apache.commons.jexl3.internal.Debugger;
+
 public final class ASTArrayLiteral extends JexlNode implements JexlNode.Literal<Object> {
     /** The type literal value. */
-    Object array = null;
+    private Object array = null;
     /** Whether this array is constant or not. */
-    boolean constant = false;
+    private boolean constant = false;
 
     ASTArrayLiteral(int id) {
         super(id);
@@ -30,6 +33,16 @@ public final class ASTArrayLiteral exten
         super(p, id);
     }
 
+    @Override
+    public String toString() {
+        Debugger dbg = new Debugger();
+        return dbg.data(this);
+    }
+
+    @Override
+    public Object getLiteral() {
+        return array;
+    }
 
     /** {@inheritDoc} */
     @Override
@@ -39,25 +52,15 @@ public final class ASTArrayLiteral exten
             constant = true;
         } else {
             constant = isConstant();
-        }
-    }
-
-    @Override
-    public Object getLiteral() {
-        return array;
-    }
-
-    /**
-     * Sets the literal value only if the descendants of this node compose a constant
-     * @param literal the literal array value
-     * @throws IllegalArgumentException if literal is not an array or null
-     */
-    public void setLiteral(Object literal) {
-        if (constant) {
-            if (literal != null && !literal.getClass().isArray()) {
-                throw new IllegalArgumentException(literal.getClass() + " is not an array");
+            if (constant) {
+                Object[] cc = new Object[children.length];
+                for(int c = 0; c < children.length; ++c) {
+                    cc[c] = ((JexlNode.Literal<?>) children[c]).getLiteral();
+                }
+                array = JexlArithmetic.typeArray(cc);
+            } else {
+                array = null;
             }
-            this.array = literal;
         }
     }
 

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ASTIdentifier.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ASTIdentifier.java?rev=1341050&r1=1341049&r2=1341050&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ASTIdentifier.java (original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ASTIdentifier.java Mon May 21 14:39:22 2012
@@ -20,27 +20,40 @@ package org.apache.commons.jexl3.parser;
  * Identifiers, variables, ie symbols.
  */
 public class ASTIdentifier extends JexlNode {
-    private int register = -1;
-    public ASTIdentifier(int id) {
+    private String name = null;
+    private int symbol = -1;
+
+    ASTIdentifier(int id) {
         super(id);
     }
 
-    public ASTIdentifier(Parser p, int id) {
+    ASTIdentifier(Parser p, int id) {
         super(p, id);
     }
 
-    void setSymbol(String r) {
-        if (r.charAt(0) == '#') {
-            register = Integer.parseInt(r.substring(1));
+    @Override
+    public String toString() {
+        return name;
+    }
+
+    void setSymbol(String identifier) {
+        if (identifier.charAt(0) == '#') {
+            symbol = Integer.parseInt(identifier.substring(1));
         }
+        name = identifier;
     }
 
-    void setSymbol(int r) {
-        register = r;
+    void setSymbol(int r, String identifier) {
+        symbol = r;
+        name = identifier;
     }
 
     public int getSymbol() {
-        return register;
+        return symbol;
+    }
+
+    public String getName() {
+        return name;
     }
 
     @Override

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ASTIdentifierAccess.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ASTIdentifierAccess.java?rev=1341050&r1=1341049&r2=1341050&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ASTIdentifierAccess.java (original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ASTIdentifierAccess.java Mon May 21 14:39:22 2012
@@ -19,32 +19,37 @@ package org.apache.commons.jexl3.parser;
 /**
  * Identifiers, variables and registers.
  */
-public class ASTIdentifierAccess extends JexlNode {
+public final class ASTIdentifierAccess extends JexlNode {
+    private String name = null;
     private Integer identifier = null;
-    
-    public ASTIdentifierAccess(int id) {
+
+    ASTIdentifierAccess(int id) {
         super(id);
     }
 
-    public ASTIdentifierAccess(Parser p, int id) {
+    ASTIdentifierAccess(Parser p, int id) {
         super(p, id);
     }
 
-    @Override
-    public Object jjtAccept(ParserVisitor visitor, Object data) {
-        return visitor.visit(this, data);
-    }
-    
-    public void setIdentifier(String id) {
-        image = id;
+    void setIdentifier(String id) {
+        name = id;
         try {
             identifier = Integer.valueOf(id);
         } catch(NumberFormatException xnumber) {
             identifier = null;
         }
     }
-    
+
     public Object getIdentifier() {
-        return identifier != null? identifier : image;
+        return identifier != null? identifier : name;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public Object jjtAccept(ParserVisitor visitor, Object data) {
+        return visitor.visit(this, data);
     }
 }

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ASTJexlLambda.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ASTJexlLambda.java?rev=1341050&r1=1341049&r2=1341050&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ASTJexlLambda.java (original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ASTJexlLambda.java Mon May 21 14:39:22 2012
@@ -21,15 +21,15 @@ import org.apache.commons.jexl3.internal
 /**
  * Enhanced script to allow parameters declaration.
  */
-public class ASTJexlLambda extends ASTJexlScript {
-    public ASTJexlLambda(int id) {
+public final class ASTJexlLambda extends ASTJexlScript {
+    ASTJexlLambda(int id) {
         super(id);
     }
 
-    public ASTJexlLambda(Parser p, int id) {
+    ASTJexlLambda(Parser p, int id) {
         super(p, id);
     }
-        
+
     /**
      * Creates an array of arguments by copying values up to the number of parameters.
      * @param values the argument values

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ASTMapLiteral.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ASTMapLiteral.java?rev=1341050&r1=1341049&r2=1341050&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ASTMapLiteral.java (original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ASTMapLiteral.java Mon May 21 14:39:22 2012
@@ -18,12 +18,13 @@ package org.apache.commons.jexl3.parser;
 
 import java.util.Collections;
 import java.util.Map;
+import org.apache.commons.jexl3.internal.Debugger;
 
 public final class ASTMapLiteral extends JexlNode implements JexlNode.Literal<Object> {
     /** The type literal value. */
-    Map<?,?> map = null;
+    private Map<?,?> map = null;
     /** Whether this array is constant or not. */
-    boolean constant = false;
+    private boolean constant = false;
 
     ASTMapLiteral(int id) {
         super(id);
@@ -34,34 +35,26 @@ public final class ASTMapLiteral extends
     }
 
 
-    /** {@inheritDoc} */
     @Override
-    public void jjtClose() {
-        if (children == null || children.length == 0) {
-            map = Collections.EMPTY_MAP;
-            constant = true;
-        } else {
-            constant = isConstant();
-        }
+    public String toString() {
+        Debugger dbg = new Debugger();
+        return dbg.data(this);
     }
 
-    /**
-     *  Gets the literal value.
-     * @return the array literal
-     */
-    public Object getLiteral() {
+    @Override
+    public Map<?,?> getLiteral() {
         return map;
     }
 
     /**
-     * Sets the literal value only if the descendants of this node compose a constant
+     * Sets the literal value only if the descendants of this node compose a constant.
      * @param literal the literal array value
      * @throws IllegalArgumentException if literal is not an array or null
      */
-    public void setLiteral(Object literal) {
+    void setLiteral(Object literal) {
         if (constant) {
             if (!(literal instanceof Map<?,?>)) {
-                throw new IllegalArgumentException(literal.getClass() + " is not an array");
+                throw new IllegalArgumentException(literal.getClass() + " is not a map");
             }
             this.map = (Map<?,?>) literal;
         }
@@ -72,4 +65,15 @@ public final class ASTMapLiteral extends
     public Object jjtAccept(ParserVisitor visitor, Object data) {
         return visitor.visit(this, data);
     }
+
+    /** {@inheritDoc} */
+    @Override
+    public void jjtClose() {
+        if (children == null || children.length == 0) {
+            map = Collections.EMPTY_MAP;
+            constant = true;
+        } else {
+            constant = isConstant();
+        }
+    }
 }

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ASTNumberLiteral.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ASTNumberLiteral.java?rev=1341050&r1=1341049&r2=1341050&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ASTNumberLiteral.java (original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ASTNumberLiteral.java Mon May 21 14:39:22 2012
@@ -19,21 +19,40 @@ package org.apache.commons.jexl3.parser;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 
-public class ASTNumberLiteral extends JexlNode implements JexlNode.Literal<Number> {
+public final class ASTNumberLiteral extends JexlNode implements JexlNode.Literal<Number> {
     /** The type literal value. */
-    Number literal = null;
+    private Number literal = null;
     /** The expected class. */
-    Class<?> clazz = null;
+    private Class<?> clazz = null;
 
-    public ASTNumberLiteral(int id) {
+    ASTNumberLiteral(int id) {
         super(id);
     }
 
-    public ASTNumberLiteral(Parser p, int id) {
+    ASTNumberLiteral(Parser p, int id) {
         super(p, id);
     }
 
     @Override
+    public String toString() {
+        StringBuilder strb = new StringBuilder(literal.toString());
+        if (clazz != null) {
+            if (Float.class.equals(clazz)) {
+                strb.append('f');
+            } else if (Double.class.equals(clazz)) {
+                strb.append('d');
+            } else if (BigDecimal.class.equals(clazz)) {
+                strb.append('b');
+            } else if (BigInteger.class.equals(clazz)) {
+                strb.append('h');
+            } else if (Long.class.equals(clazz)) {
+                strb.append('l');
+            }
+        }
+        return strb.toString();
+    }
+
+    @Override
     public Number getLiteral() {
         return literal;
     }
@@ -44,12 +63,6 @@ public class ASTNumberLiteral extends Je
         return true;
     }
 
-    /** {@inheritDoc} */
-    @Override
-    public Object jjtAccept(ParserVisitor visitor, Object data) {
-        return visitor.visit(this, data);
-    }
-
     public Class<?> getLiteralClass() {
         return clazz;
     }
@@ -63,7 +76,7 @@ public class ASTNumberLiteral extends Je
      * Originally from OGNL.
      * @param s the natural as string
      */
-    public void setNatural(String s) {
+    void setNatural(String s) {
         Number result;
         Class<?> rclass;
         // determine the base
@@ -114,7 +127,7 @@ public class ASTNumberLiteral extends Je
      * Originally from OGNL.
      * @param s the real as string
      */
-    public void setReal(String s) {
+     void setReal(String s) {
         Number result;
         Class<?> rclass;
         final int last = s.length() - 1;
@@ -149,4 +162,10 @@ public class ASTNumberLiteral extends Je
         literal = result;
         clazz = rclass;
     }
+
+    /** {@inheritDoc} */
+    @Override
+    public Object jjtAccept(ParserVisitor visitor, Object data) {
+        return visitor.visit(this, data);
+    }
 }

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ASTReferenceExpression.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ASTReferenceExpression.java?rev=1341050&r1=1341049&r2=1341050&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ASTReferenceExpression.java (original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ASTReferenceExpression.java Mon May 21 14:39:22 2012
@@ -17,11 +17,11 @@
 package org.apache.commons.jexl3.parser;
 
 public final class ASTReferenceExpression extends JexlNode {
-    public ASTReferenceExpression(int id) {
+    ASTReferenceExpression(int id) {
         super(id);
     }
 
-    public ASTReferenceExpression(Parser p, int id) {
+    ASTReferenceExpression(Parser p, int id) {
         super(p, id);
     }
 

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ASTStringLiteral.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ASTStringLiteral.java?rev=1341050&r1=1341049&r2=1341050&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ASTStringLiteral.java (original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ASTStringLiteral.java Mon May 21 14:39:22 2012
@@ -18,28 +18,40 @@ package org.apache.commons.jexl3.parser;
 
 public final class ASTStringLiteral extends JexlNode implements JexlNode.Literal<String> {
 
-    public ASTStringLiteral(int id) {
+    ASTStringLiteral(int id) {
         super(id);
     }
 
-    public ASTStringLiteral(Parser p, int id) {
+    ASTStringLiteral(Parser p, int id) {
         super(p, id);
     }
 
+    @Override
+    public String toString() {
+        return value.toString();
+    }
+
     /**
      * Gets the literal value.
      * @return the string literal
      */
+    @Override
     public String getLiteral() {
-        return image;
+        return value.toString();
     }
-    
+
+
     /** {@inheritDoc} */
     @Override
     protected boolean isConstant(boolean literal) {
         return true;
     }
     
+    void setLiteral(String literal) {
+        value = literal;
+    }
+
+
     /** {@inheritDoc} */
     @Override
     public Object jjtAccept(ParserVisitor visitor, Object data) {

Added: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/JavaccError.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/JavaccError.java?rev=1341050&view=auto
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/JavaccError.java (added)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/JavaccError.java Mon May 21 14:39:22 2012
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.jexl3.parser;
+
+/**
+ * The common info provided by Javacc errors.
+ */
+public interface JavaccError {
+
+    /**
+     * Gets the line number.
+     * @return line number.
+     */
+    int getLine();
+
+    /**
+     * Gets the column number.
+     * @return the column.
+     */
+    int getColumn();
+
+    /**
+     * Gets the last correct input.
+     * @return the string after which the error occured
+     */
+    String getAfter();
+}

Propchange: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/JavaccError.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/JexlNode.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/JexlNode.java?rev=1341050&r1=1341049&r2=1341050&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/JexlNode.java (original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/JexlNode.java Mon May 21 14:39:22 2012
@@ -35,10 +35,6 @@ public abstract class JexlNode extends S
     public interface Literal<T> {
         T getLiteral();
     }
-    /**
-     * token value.
-     */
-    public String image;
 
     public JexlNode(int id) {
         super(id);
@@ -64,15 +60,6 @@ public abstract class JexlNode extends S
         return null;
     }
 
-    @Override
-    public String toString() {
-        if (image != null) {
-            return super.toString() + ":{" + image + "}";
-        } else {
-            return super.toString();
-        }
-    }
-
     /**
      * Clears any cached value of type JexlProperty{G,S}et or JexlMethod.
      * <p>This is called when the engine detects the evaluation of a script occurs with a class loader

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java?rev=1341050&r1=1341049&r2=1341050&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java (original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java Mon May 21 14:39:22 2012
@@ -24,7 +24,6 @@ import java.util.Stack;
 
 /**
  * The base class for parsing, manages the parameter/local variable frame.
- * @author henri
  */
 public abstract class JexlParser extends StringParser {
     /**
@@ -85,7 +84,7 @@ public abstract class JexlParser extends
         if (frame != null) {
             Integer register = frame.getSymbol(image);
             if (register != null) {
-                identifier.setSymbol(register.intValue());
+                identifier.setSymbol(register.intValue(), image);
             }
         }
         return image;
@@ -102,21 +101,19 @@ public abstract class JexlParser extends
             frame = new Scope(null, (String[]) null);
         }
         Integer register = frame.declareVariable(image);
-        identifier.setSymbol(register.intValue());
-        identifier.image = image;
+        identifier.setSymbol(register.intValue(), image);
     }
 
     /**
      * Declares a local parameter.
      * <p> This method creates an new entry in the symbol map. </p>
-     * @param identifier the identifier used to declare
-     * @param image the variable name
+     * @param identifier the parameter name
      */
-    public void declareParameter(String image) {
+    public void declareParameter(String identifier) {
         if (frame == null) {
             frame = new Scope(null, (String[]) null);
         }
-        frame.declareParameter(image);
+        frame.declareParameter(identifier);
     }
 
     /**

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ParseException.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ParseException.java?rev=1341050&r1=1341049&r2=1341050&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ParseException.java (original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ParseException.java Mon May 21 14:39:22 2012
@@ -20,7 +20,7 @@ package org.apache.commons.jexl3.parser;
 /**
  * This exception is thrown when parse errors are encountered.
  */
-public class ParseException extends Exception {
+public class ParseException extends Exception implements JavaccError {
     /**
      * The version identifier.
      */
@@ -37,32 +37,8 @@ public class ParseException extends Exce
      * Error column.
      */
     private int column = -1;
-    
-    /**
-     * Gets the line number.
-     * @return line number.
-     */
-    public int getLine() {
-        return line;
-    }
 
     /**
-     * Gets the column number.
-     * @return the column.
-     */
-    public int getColumn() {
-        return column;
-    }
-    
-    /**
-     * Gets the last correct input.
-     * @return the string after which the error occured
-     */
-    public String getAfter() {
-        return after;
-    }
-    
-    /**
      * This constructor is used by the method "generateParseException"
      * in the generated parser.  Calling this constructor generates
      * a new object of this type with the fields "currentToken",
@@ -96,4 +72,19 @@ public class ParseException extends Exce
     public ParseException(String message) {
         super(message);
     }
+
+    @Override
+    public int getLine() {
+        return line;
+    }
+
+    @Override
+    public int getColumn() {
+        return column;
+    }
+
+    @Override
+    public String getAfter() {
+        return after;
+    }
 }

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt?rev=1341050&r1=1341049&r2=1341050&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt (original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt Mon May 21 14:39:22 2012
@@ -412,9 +412,9 @@ void Identifier(boolean top) :
     Token t;
 }
 {
-    t=<IDENTIFIER> { jjtThis.image = top? checkVariable(jjtThis, t.image) : t.image; }
+    t=<IDENTIFIER> { jjtThis.setSymbol(top? checkVariable(jjtThis, t.image) : t.image); }
 |
-    t=<REGISTER> { jjtThis.image = t.image; jjtThis.setSymbol(t.image); }
+    t=<REGISTER> { jjtThis.setSymbol(t.image); }
 }
 
 void StringIdentifier() #Identifier :
@@ -424,7 +424,7 @@ void StringIdentifier() #Identifier :
 {
   t=<STRING_LITERAL>
   {
-    jjtThis.image = Parser.buildString(t.image, true);
+    jjtThis.setSymbol(Parser.buildString(t.image, true));
   }
 }
 
@@ -463,7 +463,7 @@ void IntegerLiteral() #NumberLiteral :
 }
 {
   t=<INTEGER_LITERAL>
-  { jjtThis.image = t.image; jjtThis.setNatural(t.image); }
+  { jjtThis.setNatural(t.image); }
 }
 
 
@@ -473,7 +473,7 @@ void FloatLiteral() #NumberLiteral:
 }
 {
   t=<FLOAT_LITERAL>
-  { jjtThis.image = t.image; jjtThis.setReal(t.image); }
+  { jjtThis.setReal(t.image); }
 }
 
 void StringLiteral() :
@@ -482,7 +482,7 @@ void StringLiteral() :
 }
 {
   t=<STRING_LITERAL>
-  { jjtThis.image = Parser.buildString(t.image, true); }
+  { jjtThis.setLiteral(Parser.buildString(t.image, true)); }
 }
 
 void ArrayLiteral() : {}



Mime
View raw message