Author: wglass
Date: Wed Oct 26 07:05:42 2005
New Revision: 328649

URL: http://svn.apache.org/viewcvs?rev=328649&view=rev
Log:
avoid conflict with 1.5 vs 1.4 constructor

Modified:
    
jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/parser/node/MathUtils.java

Modified: 
jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/parser/node/MathUtils.java
URL: 
http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/parser/node/MathUtils.java?rev=328649&r1=328648&r2=328649&view=diff
==============================================================================
--- 
jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/parser/node/MathUtils.java
 (original)
+++ 
jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/parser/node/MathUtils.java
 Wed Oct 26 07:05:42 2005
@@ -50,8 +50,7 @@
     /**
      * A BigDecimal representing the number 0
      */
-    protected static final BigDecimal DECIMAL_ZERO    = new BigDecimal ( 0 );
-    protected static final BigInteger INT_ZERO        = BigInteger.valueOf( 0 
);
+    protected static final BigDecimal DECIMAL_ZERO    = new BigDecimal ( 
BigInteger.ZERO );
 
     /**
      * The constants are used to determine in which context we have to 
calculate.
@@ -92,15 +91,15 @@
     /**
      * Convert the given Number to a BigDecimal
      */
-    public static BigDecimal toBigDecimal (Number n) 
+    public static BigDecimal toBigDecimal (Number n)
     {
 
-        if (n instanceof BigDecimal) 
+        if (n instanceof BigDecimal)
         {
             return (BigDecimal)n;
         }
 
-        if (n instanceof BigInteger) 
+        if (n instanceof BigInteger)
         {
             return new BigDecimal ( (BigInteger)n );
         }
@@ -112,10 +111,10 @@
     /**
      * Convert the given Number to a BigInteger
      */
-    public static BigInteger toBigInteger (Number n) 
+    public static BigInteger toBigInteger (Number n)
     {
 
-        if (n instanceof BigInteger) 
+        if (n instanceof BigInteger)
         {
             return (BigInteger)n;
         }
@@ -127,21 +126,21 @@
     /**
      * Compare the given Number to 0.
      */
-    public static boolean isZero (Number n) 
+    public static boolean isZero (Number n)
     {
-        if (isInteger( n ) ) 
+        if (isInteger( n ) )
         {
-            if (n instanceof BigInteger) 
+            if (n instanceof BigInteger)
             {
-                return ((BigInteger)n).compareTo (INT_ZERO) == 0;
+                return ((BigInteger)n).compareTo (BigInteger.ZERO) == 0;
             }
             return n.doubleValue() == 0;
         }
-        if (n instanceof Float) 
+        if (n instanceof Float)
         {
             return n.floatValue() == 0f;
         }
-        if (n instanceof Double) 
+        if (n instanceof Double)
         {
             return n.doubleValue() == 0d;
         }
@@ -152,7 +151,7 @@
      * Test, whether the given object is an integer value
      * (Byte, Short, Integer, Long, BigInteger)
      */
-    public static boolean isInteger (Number n) 
+    public static boolean isInteger (Number n)
     {
         return ints.containsKey (n.getClass());
     }
@@ -161,42 +160,42 @@
      * Wrap the given primitive into the given class if the value is in the
      * range of the destination type. If not the next bigger type will be 
chosen.
      */
-    public static Number wrapPrimitive (long value, Class type) 
+    public static Number wrapPrimitive (long value, Class type)
     {
-        if (type == Byte.class) 
+        if (type == Byte.class)
         {
-            if (value > Byte.MAX_VALUE || value < Byte.MIN_VALUE) 
+            if (value > Byte.MAX_VALUE || value < Byte.MIN_VALUE)
             {
                 type = Short.class;
-            } 
-            else 
+            }
+            else
             {
                 return new Byte ((byte)value);
             }
         }
-        if (type == Short.class) 
+        if (type == Short.class)
         {
-            if (value > Short.MAX_VALUE || value < Short.MIN_VALUE) 
+            if (value > Short.MAX_VALUE || value < Short.MIN_VALUE)
             {
                 type = Integer.class;
-            } 
-            else 
+            }
+            else
             {
                 return new Short((short)value);
             }
         }
-        if (type == Integer.class) 
+        if (type == Integer.class)
         {
-            if (value > Integer.MAX_VALUE || value < Integer.MIN_VALUE) 
+            if (value > Integer.MAX_VALUE || value < Integer.MIN_VALUE)
             {
                 type = Long.class;
-            } 
-            else 
+            }
+            else
             {
                 return new Integer ((int)value);
             }
         }
-        if (type == Long.class) 
+        if (type == Long.class)
         {
             return new Long (value);
         }
@@ -206,9 +205,9 @@
     /**
      * Wrap the result in the object of the bigger type.
      */
-    private static Number wrapPrimitive (long value, Number op1, Number op2) 
+    private static Number wrapPrimitive (long value, Number op1, Number op2)
     {
-        if ( typesBySize.indexOf( op1.getClass()) > typesBySize.indexOf( 
op2.getClass())) 
+        if ( typesBySize.indexOf( op1.getClass()) > typesBySize.indexOf( 
op2.getClass()))
         {
             return wrapPrimitive( value, op1.getClass());
         }
@@ -218,27 +217,27 @@
     /**
      * Find the common Number-type to be used in calculations.
      */
-    private static int findCalculationBase (Number op1, Number op2) 
+    private static int findCalculationBase (Number op1, Number op2)
     {
 
         boolean op1Int = isInteger(op1);
         boolean op2Int = isInteger(op2);
 
         if ( (op1 instanceof BigDecimal || op2 instanceof BigDecimal) ||
-             ( (!op1Int || !op2Int) && (op1 instanceof BigInteger || op2 
instanceof BigInteger)) ) 
+             ( (!op1Int || !op2Int) && (op1 instanceof BigInteger || op2 
instanceof BigInteger)) )
         {
             return BASE_BIGDECIMAL;
         }
 
         if (op1Int && op2Int) {
-            if (op1 instanceof BigInteger || op2 instanceof BigInteger) 
+            if (op1 instanceof BigInteger || op2 instanceof BigInteger)
             {
                 return BASE_BIGINTEGER;
             }
             return BASE_LONG;
         }
 
-        if ((op1 instanceof Double) || (op2 instanceof Double)) 
+        if ((op1 instanceof Double) || (op2 instanceof Double))
         {
             return BASE_DOUBLE;
         }
@@ -249,11 +248,11 @@
      * Add two numbers and return the correct value / type.
      * Overflow detection is done for integer values (byte, short, int, long) 
only!
      */
-    public static Number add (Number op1, Number op2) 
+    public static Number add (Number op1, Number op2)
     {
 
         int calcBase = findCalculationBase( op1, op2);
-        switch (calcBase) 
+        switch (calcBase)
         {
             case BASE_BIGINTEGER:
                 return toBigInteger( op1 ).add( toBigInteger( op2 ));
@@ -263,7 +262,7 @@
                 long result = l1+l2;
 
                 // Overflow check
-                if ((result ^ l1) < 0 && (result ^ l2) < 0) 
+                if ((result ^ l1) < 0 && (result ^ l2) < 0)
                 {
                     return toBigInteger( op1).add( toBigInteger( op2));
                 }
@@ -343,8 +342,8 @@
 
     /**
      * Divide two numbers. The result will be returned as Integer-type if and 
only if
-     * both sides of the division operator are Integer-types. Otherwise a 
Float, Double, 
-     * or BigDecimal will be returned. 
+     * both sides of the division operator are Integer-types. Otherwise a 
Float, Double,
+     * or BigDecimal will be returned.
      */
     public static Number divide (Number op1, Number op2) {
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to