commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r377889 - in /jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser: ASTAddNode.java ASTModNode.java ASTMulNode.java ASTSubtractNode.java
Date Tue, 14 Feb 2006 23:48:01 GMT
Author: dion
Date: Tue Feb 14 15:47:59 2006
New Revision: 377889

URL: http://svn.apache.org/viewcvs?rev=377889&view=rev
Log:
Remove 'unwiden'ing of numeric values which was introduced to 
fix Bug 32829.

A better solution is to fix the ASTMethod class to narrow the parameters,
rather than change JEXL's public 'contract' of using Long's for integer values.

Modified:
    jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser/ASTAddNode.java
    jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser/ASTModNode.java
    jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser/ASTMulNode.java
    jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser/ASTSubtractNode.java

Modified: jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser/ASTAddNode.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser/ASTAddNode.java?rev=377889&r1=377888&r2=377889&view=diff
==============================================================================
--- jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser/ASTAddNode.java
(original)
+++ jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser/ASTAddNode.java
Tue Feb 14 15:47:59 2006
@@ -54,7 +54,7 @@
          *  the spec says 'and'
          */
         if (left == null && right == null)
-            return new Byte((byte)0);
+            return new Long(0);
 
         /*
          *  if anything is float, double or string with ( "." | "E" | "e")
@@ -103,8 +103,7 @@
         {
             Long l = left == null ? new Long(0) : Coercion.coerceLong(left);
             Long r = right == null ? new Long(0) : Coercion.coerceLong(right);
-            Long result = new Long(l.longValue() + r.longValue());
-            return unwiden(result);
+            return new Long(l.longValue() + r.longValue());
         }
         catch( java.lang.NumberFormatException nfe )
         {
@@ -113,30 +112,5 @@
              */
             return left.toString().concat(right.toString());
         }
-    }
-    
-    /**
-     * Given a long, return back the smallest type the result will fit into.
-     * This works hand in hand with parameter 'widening' in java method calls,
-     * e.g. a call to substring(int,int) with an int and a long will fail, but
-     * a call to substring(int,int) with an int and a short will succeed.
-     * @since 1.0.1
-     */
-    public static Number unwiden(Long result)
-    {
-        if (result.longValue() <= Byte.MAX_VALUE && result.longValue() >= Byte.MIN_VALUE)
-        {
-            // it will fit in a byte
-            return new Byte((byte)result.longValue());
-        }
-        else if (result.longValue() <= Short.MAX_VALUE && result.longValue() >=
Short.MIN_VALUE)
-        {
-            return new Short((short)result.longValue());
-        }
-        else if (result.longValue() <= Integer.MAX_VALUE && result.longValue()
>= Integer.MIN_VALUE)
-        {
-            return new Integer((int)result.longValue());
-        }
-        return result;
     }
 }

Modified: jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser/ASTModNode.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser/ASTModNode.java?rev=377889&r1=377888&r2=377889&view=diff
==============================================================================
--- jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser/ASTModNode.java
(original)
+++ jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser/ASTModNode.java
Tue Feb 14 15:47:59 2006
@@ -99,7 +99,7 @@
         if (r.longValue() == 0)
             return new Long(0);
 
-        return ASTAddNode.unwiden(new Long(l.longValue() % r.longValue()));
+        return new Long(l.longValue() % r.longValue());
     }
 
 }

Modified: jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser/ASTMulNode.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser/ASTMulNode.java?rev=377889&r1=377888&r2=377889&view=diff
==============================================================================
--- jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser/ASTMulNode.java
(original)
+++ jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser/ASTMulNode.java
Tue Feb 14 15:47:59 2006
@@ -87,7 +87,7 @@
         Long l = Coercion.coerceLong(left);
         Long r = Coercion.coerceLong(right);
 
-        return ASTAddNode.unwiden(new Long(l.longValue() * r.longValue()));
+        return new Long(l.longValue() * r.longValue());
     }
 
 }

Modified: jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser/ASTSubtractNode.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser/ASTSubtractNode.java?rev=377889&r1=377888&r2=377889&view=diff
==============================================================================
--- jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser/ASTSubtractNode.java
(original)
+++ jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser/ASTSubtractNode.java
Tue Feb 14 15:47:59 2006
@@ -90,8 +90,7 @@
          *  where bar wants an int... 
          * 
          */
-        long v = l.longValue() - r.longValue();
-        return ASTAddNode.unwiden(new Long(v));
+        return new Long(l.longValue() - r.longValue());
 
      }
     /** Accept the visitor. **/



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message