commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hen...@apache.org
Subject svn commit: r1197614 - in /commons/proper/jexl/trunk: pom.xml src/main/java/org/apache/commons/jexl2/JexlEngine.java src/main/java/org/apache/commons/jexl2/UnifiedJEXL.java src/site/site.xml
Date Fri, 04 Nov 2011 15:57:12 GMT
Author: henrib
Date: Fri Nov  4 15:57:11 2011
New Revision: 1197614

URL: http://svn.apache.org/viewvc?rev=1197614&view=rev
Log:
Revert to snapshot build to fix jexl-compat

Modified:
    commons/proper/jexl/trunk/pom.xml
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/JexlEngine.java
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/UnifiedJEXL.java
    commons/proper/jexl/trunk/src/site/site.xml

Modified: commons/proper/jexl/trunk/pom.xml
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/pom.xml?rev=1197614&r1=1197613&r2=1197614&view=diff
==============================================================================
--- commons/proper/jexl/trunk/pom.xml (original)
+++ commons/proper/jexl/trunk/pom.xml Fri Nov  4 15:57:11 2011
@@ -24,7 +24,7 @@
     <modelVersion>4.0.0</modelVersion>
     <groupId>org.apache.commons</groupId>
     <artifactId>commons-jexl</artifactId>
-    <version>2.2-SNAPSHOT</version>
+    <version>2.1-SNAPSHOT</version>
     <name>Commons JEXL</name>
     <inceptionYear>2001</inceptionYear>
     <description>Jexl is an implementation of the JSTL Expression Language with extensions.</description>

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/JexlEngine.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/JexlEngine.java?rev=1197614&r1=1197613&r2=1197614&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/JexlEngine.java (original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/JexlEngine.java Fri Nov
 4 15:57:11 2011
@@ -1016,9 +1016,15 @@ public class JexlEngine {
          * @return true if equal, false otherwise
          */
         public boolean equals(Scope frame) {
-            return this == frame
-                    || parms == frame.parms
-                    && namedRegisters.equals(frame.namedRegisters);
+            if (this == frame) {
+                return true;
+            } else if (frame == null || parms != frame.parms) {
+                return false;
+            } else if (namedRegisters == null) {
+                return frame.namedRegisters == null;
+            } else {
+                return namedRegisters.equals(frame.namedRegisters);
+            }
         }
 
         /**

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/UnifiedJEXL.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/UnifiedJEXL.java?rev=1197614&r1=1197613&r2=1197614&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/UnifiedJEXL.java (original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/UnifiedJEXL.java Fri
Nov  4 15:57:11 2011
@@ -18,7 +18,6 @@ package org.apache.commons.jexl2;
 
 import java.io.BufferedReader;
 import java.io.IOException;
-import java.io.PrintWriter;
 import java.io.Reader;
 import java.io.StringReader;
 import java.io.Writer;
@@ -96,6 +95,7 @@ public final class UnifiedJEXL {
     private static final char IMM_CHAR = '$';
     /** The first character for deferred expressions. */
     private static final char DEF_CHAR = '#';
+
     /**
      * Creates a new instance of UnifiedJEXL with a default size cache.
      * @param aJexl the JexlEngine to use.
@@ -594,7 +594,7 @@ public final class UnifiedJEXL {
                 throw new IllegalArgumentException("Nested expression can not have a source");
             }
         }
-        
+
         @Override
         public StringBuilder asString(StringBuilder strb) {
             strb.append(expr);
@@ -1121,7 +1121,7 @@ public final class UnifiedJEXL {
             }
             return strb.toString();
         }
-        
+
         /**
          * Recreate the template source from its inner components.
          * @return the template source rewritten
@@ -1146,7 +1146,7 @@ public final class UnifiedJEXL {
          * @return the prepared version of the template
          */
         public Template prepare(JexlContext context) {
-            JexlEngine.Frame frame = script.createFrame((Object[])null);
+            JexlEngine.Frame frame = script.createFrame((Object[]) null);
             TemplateContext tcontext = new TemplateContext(context, frame, exprs, null);
             Expression[] immediates = new Expression[exprs.length];
             for (int e = 0; e < exprs.length; ++e) {
@@ -1189,7 +1189,7 @@ public final class UnifiedJEXL {
         /** The array of UnifiedJEXL expressions. */
         private final Expression[] exprs;
         /** The writer used to output. */
-        private final PrintWriter writer;
+        private final Writer writer;
         /** The call frame. */
         private final JexlEngine.Frame frame;
 
@@ -1204,13 +1204,7 @@ public final class UnifiedJEXL {
             wrap = jcontext;
             frame = jframe;
             exprs = expressions;
-            if (out == null) {
-                writer = null;
-            } else if (out instanceof PrintWriter) {
-                writer = (PrintWriter) out;
-            } else {
-                writer = new PrintWriter(out);
-            }
+            writer = out;
         }
 
         /**
@@ -1256,46 +1250,39 @@ public final class UnifiedJEXL {
         public void include(Template template, Object... args) {
             template.evaluate(wrap, writer, args);
         }
-
+        
         /**
          * Prints an expression result.
          * @param e the expression number
          */
-        public void print(int e) {
-            Expression expr = exprs[e];
+        public void print(String cs) {
+            Expression expr = UnifiedJEXL.this.parse(cs);
             if (expr.isDeferred()) {
                 expr = expr.prepare(wrap);
             }
             if (expr instanceof CompositeExpression) {
                 printComposite((CompositeExpression) expr);
             } else {
-                print(expr.evaluate(this));
+                doPrint(expr.evaluate(this));
             }
         }
 
         /**
-         * Prints to output.
-         * <p>This will dynamically try to find the best suitable method in the writer
through uberspection.
-         * Subclassing Writer should be the preferred way to specialize output.
-         * </p>
-         * @param arg the argument to print out
+         * Prints an expression result.
+         * @param e the expression number
          */
-        protected void print(Object arg) {
-            if (arg instanceof CharSequence) {
-                writer.print(arg.toString());
-            } else if (arg != null) {
-                Object[] value = {arg};
-                Uberspect uber = getEngine().getUberspect();
-                JexlMethod method = uber.getMethod(writer, "print", value, null);
-                if (method != null) {
-                    try {
-                        method.invoke(writer, value);
-                    } catch (java.lang.Exception xany) {
-                        throw createException("invoke print", null, xany);
-                    }
-                } else {
-                    writer.print(arg.toString());
-                }
+        public void print(int e) {
+            if (e < 0 || e >= exprs.length) {
+                return;
+            }
+            Expression expr = exprs[e];
+            if (expr.isDeferred()) {
+                expr = expr.prepare(wrap);
+            }
+            if (expr instanceof CompositeExpression) {
+                printComposite((CompositeExpression) expr);
+            } else {
+                doPrint(expr.evaluate(this));
             }
         }
 
@@ -1309,7 +1296,35 @@ public final class UnifiedJEXL {
             Object value = null;
             for (int e = 0; e < size; ++e) {
                 value = cexprs[e].evaluate(this);
-                print(value);
+                doPrint(value);
+            }
+        }
+        
+        /**
+         * Prints to output.
+         * <p>This will dynamically try to find the best suitable method in the writer
through uberspection.
+         * Subclassing Writer by adding 'print' methods should be the preferred way to specialize
output.
+         * </p>
+         * @param arg the argument to print out
+         */
+        private void doPrint(Object arg) {
+            try {
+                if (arg instanceof CharSequence) {
+                    writer.write(arg.toString());
+                } else if (arg != null) {
+                    Object[] value = {arg};
+                    Uberspect uber = getEngine().getUberspect();
+                    JexlMethod method = uber.getMethod(writer, "print", value, null);
+                    if (method != null) {
+                        method.invoke(writer, value);
+                    } else {
+                        writer.write(arg.toString());
+                    }
+                }
+            } catch (java.io.IOException xio) {
+                throw createException("call print", null, xio);
+            } catch (java.lang.Exception xany) {
+                throw createException("invoke print", null, xany);
             }
         }
     }
@@ -1415,7 +1430,6 @@ public final class UnifiedJEXL {
         return new Template(prefix, source, parms);
     }
 
-    
     /**
      * Creates a new template.
      * @param source the source
@@ -1434,5 +1448,4 @@ public final class UnifiedJEXL {
     public Template createTemplate(String source) {
         return new Template("$$", new StringReader(source), (String[]) null);
     }
-
 }
\ No newline at end of file

Modified: commons/proper/jexl/trunk/src/site/site.xml
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/site/site.xml?rev=1197614&r1=1197613&r2=1197614&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/site/site.xml (original)
+++ commons/proper/jexl/trunk/src/site/site.xml Fri Nov  4 15:57:11 2011
@@ -25,11 +25,10 @@
     <body>
         <menu name="Commons&#xA0;Jexl">
             <item name="Overview"                href="index.html" />
-            <item name="2.0.1&#xA0;Javadoc"        href="apidocs/index.html"/>
+            <item name="2.1&#xA0;Javadoc"        href="apidocs/index.html"/>
             <item name="1.1&#xA0;Javadoc"        href="apidocs-1.1/index.html"/>
             <item name="Download"                href="download_jexl.cgi"/>
             <item name="Reference"               href="reference/index.html"/>
-            <item name="JEXL Wiki"               href="http://wiki.apache.org/commons/JEXL"/>
         </menu>
 
         <menu name="Development">



Mime
View raw message