commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hen...@apache.org
Subject svn commit: r1208830 - in /commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl2: JexlArithmetic.java JexlEngine.java
Date Wed, 30 Nov 2011 22:10:56 GMT
Author: henrib
Date: Wed Nov 30 22:10:55 2011
New Revision: 1208830

URL: http://svn.apache.org/viewvc?rev=1208830&view=rev
Log:
Partial JEXL-83 fix rollback, deprecated setLenient and associated field in JexlArithmetic
in an attempt to release 2.1

Modified:
    commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl2/JexlArithmetic.java
    commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl2/JexlEngine.java

Modified: commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl2/JexlArithmetic.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl2/JexlArithmetic.java?rev=1208830&r1=1208829&r2=1208830&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl2/JexlArithmetic.java
(original)
+++ commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl2/JexlArithmetic.java
Wed Nov 30 22:10:55 2011
@@ -55,7 +55,8 @@ public class JexlArithmetic {
     /** Default BigDecimal scale. */
     protected static final int BIGD_SCALE = -1;
     /** Whether this JexlArithmetic instance behaves in strict or lenient mode. */
-    protected final boolean strict;
+    /** @deprecated : will become final in next version. */
+    protected boolean strict;
     /** The big decimal math context. */
     protected final MathContext mathContext;
     /** The big decimal scale. */
@@ -81,6 +82,22 @@ public class JexlArithmetic {
         this.mathContext = bigdContext;
         this.mathScale = bigdScale;
     }
+    
+    
+    /**
+     * Sets whether this JexlArithmetic instance triggers errors during evaluation when
+     * null is used as an operand.
+     * <p>This method is <em>not</em> thread safe; it may be called as
an optional step by the JexlEngine
+     * in its initialization code before expression creation &amp; evaluation.</p>
+     * @see JexlEngine#setSilent
+     * @see JexlEngine#setDebug
+     * @param flag true means no JexlException will occur, false allows them
+     * @deprecated as of 2.1
+     */
+    @Deprecated
+    void setLenient(boolean flag) {
+        this.strict = !flag;
+    }
 
     /**
      * Checks whether this JexlArithmetic instance triggers errors during evaluation
@@ -101,7 +118,7 @@ public class JexlArithmetic {
     }
 
     /**
-     * The BigDecimal scale used for comparison and coericion operations.
+     * The BigDecimal scale used for comparison and coercion operations.
      * @return the scale
      * @since 2.1
      */

Modified: commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl2/JexlEngine.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl2/JexlEngine.java?rev=1208830&r1=1208829&r2=1208830&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl2/JexlEngine.java
(original)
+++ commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl2/JexlEngine.java
Wed Nov 30 22:10:55 2011
@@ -157,8 +157,9 @@ public class JexlEngine {
     protected boolean silent = false;
     /**
      * Whether this engine is in lenient or strict mode; if unspecified, use the arithmetic
lenient property.
+     * Provision for version after 2.1.
      */
-    protected Boolean strict = null;
+    // protected Boolean strict = null;
     /**
      * Whether error messages will carry debugging information.
      */
@@ -274,23 +275,25 @@ public class JexlEngine {
     public boolean isSilent() {
         return this.silent;
     }
-
+    
     /**
      * Sets whether this engine considers unknown variables, methods and constructors as
errors or evaluates them
      * as null.
      * <p>This method is <em>not</em> thread safe; it should be called
as an optional step of the JexlEngine
      * initialization code before expression creation &amp; evaluation.</p>
-     * <p>As of 2.1, you need a JexlThreadedArithmetic instance for this call to also
modify the JexlArithmetic
+     * <p>After 2.1, you will need a JexlThreadedArithmetic instance for this call
to also modify the JexlArithmetic
      * leniency behavior.</p>
      * @see JexlEngine#setSilent
      * @see JexlEngine#setDebug
      * @param flag true means no JexlException will occur, false allows them
      */
+    @SuppressWarnings("deprecation")
     public void setLenient(boolean flag) {
         if (arithmetic instanceof JexlThreadedArithmetic) {
             JexlThreadedArithmetic.setLenient(Boolean.valueOf(flag));
         } else {
-            strict = flag ? Boolean.FALSE : Boolean.TRUE;
+            //strict = flag ? Boolean.FALSE : Boolean.TRUE;
+            this.arithmetic.setLenient(flag);
         }
     }
 
@@ -300,7 +303,8 @@ public class JexlEngine {
      * @return true if lenient, false if strict
      */
     public boolean isLenient() {
-        return strict == null ? arithmetic.isLenient() : !strict.booleanValue();
+        //return strict == null ? arithmetic.isLenient() : !strict.booleanValue();
+        return this.arithmetic.isLenient();
     }
 
     /**



Mime
View raw message