commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r1073658 - in /commons/proper/math/branches/MATH_2_X/src: main/java/org/apache/commons/math/exception/ main/java/org/apache/commons/math/fraction/ main/java/org/apache/commons/math/optimization/ main/java/org/apache/commons/math/util/ test/...
Date Wed, 23 Feb 2011 09:45:42 GMT
Author: luc
Date: Wed Feb 23 09:45:42 2011
New Revision: 1073658

URL: http://svn.apache.org/viewvc?rev=1073658&view=rev
Log:
another round of exception incompatibilities squashing

Modified:
    commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/exception/NoDataException.java
    commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/fraction/BigFraction.java
    commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/UnivariateRealOptimizer.java
    commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/util/DefaultTransformer.java
    commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/fraction/BigFractionTest.java
    commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/util/DefaultTransformerTest.java

Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/exception/NoDataException.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/exception/NoDataException.java?rev=1073658&r1=1073657&r2=1073658&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/exception/NoDataException.java
(original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/exception/NoDataException.java
Wed Feb 23 09:45:42 2011
@@ -25,7 +25,7 @@ import org.apache.commons.math.exception
  * @since 2.2
  * @version $Revision$ $Date$
  */
-public class NoDataException extends MathIllegalArgumentException {
+public class NoDataException extends MathIllegalStateException {
 
     /** Serializable version Id. */
     private static final long serialVersionUID = -3629324471511904459L;

Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/fraction/BigFraction.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/fraction/BigFraction.java?rev=1073658&r1=1073657&r2=1073658&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/fraction/BigFraction.java
(original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/fraction/BigFraction.java
Wed Feb 23 09:45:42 2011
@@ -23,7 +23,6 @@ import java.math.BigInteger;
 import org.apache.commons.math.FieldElement;
 import org.apache.commons.math.MathRuntimeException;
 import org.apache.commons.math.exception.util.LocalizedFormats;
-import org.apache.commons.math.exception.NullArgumentException;
 import org.apache.commons.math.util.MathUtils;
 import org.apache.commons.math.util.FastMath;
 
@@ -115,10 +114,10 @@ public class BigFraction
      */
     public BigFraction(BigInteger num, BigInteger den) {
         if (num == null) {
-            throw new NullArgumentException(LocalizedFormats.NUMERATOR);
+            throw new NullPointerException(LocalizedFormats.NUMERATOR.getSourceString());
         }
         if (den == null) {
-            throw new NullArgumentException(LocalizedFormats.DENOMINATOR);
+            throw new NullPointerException(LocalizedFormats.DENOMINATOR.getSourceString());
         }
         if (BigInteger.ZERO.equals(den)) {
             throw MathRuntimeException.createArithmeticException(LocalizedFormats.ZERO_DENOMINATOR);
@@ -501,11 +500,11 @@ public class BigFraction
      * @param fraction
      *            the {@link BigFraction} to add, must not be <code>null</code>.
      * @return a {@link BigFraction} instance with the resulting values.
-     * @throws NullArgumentException if the {@link BigFraction} is {@code null}.
+     * @throws NullPointerException if the {@link BigFraction} is {@code null}.
      */
     public BigFraction add(final BigFraction fraction) {
         if (fraction == null) {
-            throw new NullArgumentException(LocalizedFormats.FRACTION);
+            throw new NullPointerException(LocalizedFormats.FRACTION.getSourceString());
         }
         if (ZERO.equals(fraction)) {
             return this;
@@ -657,12 +656,12 @@ public class BigFraction
      *
      * @param fraction Fraction to divide by, must not be {@code null}.
      * @return a {@link BigFraction} instance with the resulting values.
-     * @throws NullArgumentException if the {@code fraction} is {@code null}.
+     * @throws NullPointerException if the {@code fraction} is {@code null}.
      * @throws ArithmeticException if the fraction to divide by is zero.
      */
     public BigFraction divide(final BigFraction fraction) {
         if (fraction == null) {
-            throw new NullArgumentException(LocalizedFormats.FRACTION);
+            throw new NullPointerException(LocalizedFormats.FRACTION.getSourceString());
         }
         if (BigInteger.ZERO.equals(fraction.numerator)) {
             throw MathRuntimeException.createArithmeticException(LocalizedFormats.ZERO_DENOMINATOR);
@@ -844,11 +843,11 @@ public class BigFraction
      *
      * @param bg the {@code BigInteger} to multiply by.
      * @return a {@code BigFraction} instance with the resulting values.
-     * @throws NullArgumentException if {@code bg} is {@code null}.
+     * @throws NullPointerException if {@code bg} is {@code null}.
      */
     public BigFraction multiply(final BigInteger bg) {
         if (bg == null) {
-            throw new NullArgumentException();
+            throw new NullPointerException();
         }
         return new BigFraction(bg.multiply(numerator), denominator);
     }
@@ -889,11 +888,11 @@ public class BigFraction
      *
      * @param fraction Fraction to multiply by, must not be {@code null}.
      * @return a {@link BigFraction} instance with the resulting values.
-     * @throws NullArgumentException if {@code fraction} is {@code null}.
+     * @throws NullPointerException if {@code fraction} is {@code null}.
      */
     public BigFraction multiply(final BigFraction fraction) {
         if (fraction == null) {
-            throw new NullArgumentException(LocalizedFormats.FRACTION);
+            throw new NullPointerException(LocalizedFormats.FRACTION.getSourceString());
         }
         if (numerator.equals(BigInteger.ZERO) ||
             fraction.numerator.equals(BigInteger.ZERO)) {
@@ -1031,11 +1030,11 @@ public class BigFraction
      *
      * @param bg the {@link BigInteger} to subtract, cannot be {@code null}.
      * @return a {@code BigFraction} instance with the resulting values.
-     * @throws NullArgumentException if the {@link BigInteger} is {@code null}.
+     * @throws NullPointerException if the {@link BigInteger} is {@code null}.
      */
     public BigFraction subtract(final BigInteger bg) {
         if (bg == null) {
-            throw new NullArgumentException();
+            throw new NullPointerException();
         }
         return new BigFraction(numerator.subtract(denominator.multiply(bg)), denominator);
     }
@@ -1077,11 +1076,11 @@ public class BigFraction
      *
      * @param fraction {@link BigFraction} to subtract, must not be {@code null}.
      * @return a {@link BigFraction} instance with the resulting values
-     * @throws NullArgumentException if the {@code fraction} is {@code null}.
+     * @throws NullPointerException if the {@code fraction} is {@code null}.
      */
     public BigFraction subtract(final BigFraction fraction) {
         if (fraction == null) {
-            throw new NullArgumentException(LocalizedFormats.FRACTION);
+            throw new NullPointerException(LocalizedFormats.FRACTION.getSourceString());
         }
         if (ZERO.equals(fraction)) {
             return this;

Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/UnivariateRealOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/UnivariateRealOptimizer.java?rev=1073658&r1=1073657&r2=1073658&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/UnivariateRealOptimizer.java
(original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/UnivariateRealOptimizer.java
Wed Feb 23 09:45:42 2011
@@ -88,6 +88,7 @@ public interface UnivariateRealOptimizer
      * @throws FunctionEvaluationException if an error occurs evaluating the function.
      * @throws IllegalArgumentException if min > max or the arguments do not
      * satisfy the requirements specified by the optimizer.
+     * @throws IllegalStateException if there are no data.
      */
     double optimize(UnivariateRealFunction f, GoalType goalType,
                     double min, double max, double startValue)

Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/util/DefaultTransformer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/util/DefaultTransformer.java?rev=1073658&r1=1073657&r2=1073658&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/util/DefaultTransformer.java
(original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/util/DefaultTransformer.java
Wed Feb 23 09:45:42 2011
@@ -21,7 +21,6 @@ import java.io.Serializable;
 
 import org.apache.commons.math.MathException;
 import org.apache.commons.math.exception.util.LocalizedFormats;
-import org.apache.commons.math.exception.NullArgumentException;
 
 /**
  * A Default NumberTransformer for java.lang.Numbers and Numeric Strings. This
@@ -40,12 +39,11 @@ public class DefaultTransformer implemen
      * @param o  the object that gets transformed.
      * @return a double primitive representation of the Object o.
      * @throws MathException if it cannot successfully be transformed.
-     * @throws NullArgumentException if is {@code null}.
      * @see <a href="http://commons.apache.org/collections/api-release/org/apache/commons/collections/Transformer.html">Commons
Collections Transformer</a>
      */
     public double transform(Object o) throws MathException {
         if (o == null) {
-            throw new NullArgumentException(LocalizedFormats.OBJECT_TRANSFORMATION);
+            throw new MathException(LocalizedFormats.OBJECT_TRANSFORMATION);
         }
 
         if (o instanceof Number) {

Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/fraction/BigFractionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/fraction/BigFractionTest.java?rev=1073658&r1=1073657&r2=1073658&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/fraction/BigFractionTest.java
(original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/fraction/BigFractionTest.java
Wed Feb 23 09:45:42 2011
@@ -21,7 +21,6 @@ import java.math.BigInteger;
 
 import org.apache.commons.math.ConvergenceException;
 import org.apache.commons.math.TestUtils;
-import org.apache.commons.math.exception.NullArgumentException;
 import org.apache.commons.math.util.FastMath;
 
 import junit.framework.TestCase;
@@ -66,14 +65,14 @@ public class BigFractionTest extends Tes
         assertFraction(1055531162664967l, 70368744177664l, new BigFraction(15.0000000000001));
         try {
             new BigFraction(null, BigInteger.ONE);
-            fail("Expecting NullArgumentException");
-        } catch (NullArgumentException npe) {
+            fail("Expecting NullPointerException");
+        } catch (NullPointerException npe) {
             // expected
         }
         try {
             new BigFraction(BigInteger.ONE, null);
-            fail("Expecting NullArgumentException");
-        } catch (NullArgumentException npe) {
+            fail("Expecting NullPointerException");
+        } catch (NullPointerException npe) {
             // expected
         }
         try {
@@ -330,8 +329,8 @@ public class BigFractionTest extends Tes
 
         try {
             f.add((BigFraction) null);
-            fail("expecting NullArgumentException");
-        } catch (NullArgumentException ex) {
+            fail("expecting NullPointerException");
+        } catch (NullPointerException ex) {
         }
 
         // if this fraction is added naively, it will overflow.
@@ -418,8 +417,8 @@ public class BigFractionTest extends Tes
 
         try {
             f.divide((BigFraction) null);
-            fail("expecting NullArgumentException");
-        } catch (NullArgumentException ex) {
+            fail("expecting NullPointerException");
+        } catch (NullPointerException ex) {
         }
 
         f1 = new BigFraction(Integer.MIN_VALUE, Integer.MAX_VALUE);
@@ -464,8 +463,8 @@ public class BigFractionTest extends Tes
 
         try {
             f.multiply((BigFraction) null);
-            fail("expecting NullArgumentException");
-        } catch (NullArgumentException ex) {
+            fail("expecting NullPointerException");
+        } catch (NullPointerException ex) {
         }
 
     }
@@ -482,8 +481,8 @@ public class BigFractionTest extends Tes
         BigFraction f = new BigFraction(1, 1);
         try {
             f.subtract((BigFraction) null);
-            fail("expecting NullArgumentException");
-        } catch (NullArgumentException ex) {
+            fail("expecting NullPointerException");
+        } catch (NullPointerException ex) {
         }
 
         // if this fraction is subtracted naively, it will overflow.

Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/util/DefaultTransformerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/util/DefaultTransformerTest.java?rev=1073658&r1=1073657&r2=1073658&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/util/DefaultTransformerTest.java
(original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/util/DefaultTransformerTest.java
Wed Feb 23 09:45:42 2011
@@ -23,7 +23,6 @@ import junit.framework.TestCase;
 
 import org.apache.commons.math.MathException;
 import org.apache.commons.math.TestUtils;
-import org.apache.commons.math.exception.NullArgumentException;
 
 /**
  * @version $Revision$ $Date$
@@ -46,8 +45,8 @@ public class DefaultTransformerTest exte
         DefaultTransformer t = new DefaultTransformer();
         try {
             t.transform(null);
-            fail("Expecting NullArgumentException");
-        } catch (NullArgumentException e) {
+            fail("Expecting MathException");
+        } catch (MathException e) {
             // expected
         }
     }



Mime
View raw message