Author: henrib
Date: Thu Aug  4 13:53:08 2016
New Revision: 1755189

URL: http://svn.apache.org/viewvc?rev=1755189&view=rev
Log:
JEXL-201: added setting options from context

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

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=1755189&r1=1755188&r2=1755189&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
 Thu Aug  4 13:53:08 2016
@@ -133,6 +133,19 @@ public class JexlArithmetic {
     }
 
     /**
+     * Apply options to this arithmetic which eventually may create another 
instance.
+     * @see #createWithOptions(boolean, java.math.MathContext, int)
+     *
+     * @param context the context that may extend {@link JexlEngine.Options} 
to use
+     * @return a new arithmetic instance or this
+     */
+    public JexlArithmetic options(JexlContext context) {
+        return context instanceof JexlEngine.Options
+               ? options((JexlEngine.Options) context)
+               : this;
+    }
+
+    /**
      * Creates a JexlArithmetic instance.
      * Called by options(...) method when another instance of the same class 
of arithmetic is required.
      * @see #options(org.apache.commons.jexl3.JexlEngine.Options)
@@ -709,10 +722,10 @@ public class JexlArithmetic {
         // otherwise treat as integers
         BigInteger l = toBigInteger(left);
         BigInteger r = toBigInteger(right);
-        BigInteger result = l.mod(r);
         if (BigInteger.ZERO.equals(r)) {
             throw new ArithmeticException("%");
         }
+        BigInteger result = l.mod(r);
         return narrowBigInteger(left, right, result);
     }
 


Reply via email to