commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r712144 - in /commons/proper/math/branches/MATH_2_0/src: java/org/apache/commons/math/ java/org/apache/commons/math/analysis/ java/org/apache/commons/math/complex/ java/org/apache/commons/math/estimation/ java/org/apache/commons/math/fracti...
Date Fri, 07 Nov 2008 14:56:04 GMT
Author: luc
Date: Fri Nov  7 06:55:23 2008
New Revision: 712144

URL: http://svn.apache.org/viewvc?rev=712144&view=rev
Log:
improved error messages

Modified:
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/MessagesResources_fr.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/analysis/PolynomialFunctionLagrangeForm.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/complex/ComplexFormat.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/estimation/AbstractEstimator.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/estimation/GaussNewtonEstimator.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/fraction/Fraction.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/fraction/FractionFormat.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/geometry/Rotation.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/geometry/Vector3D.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/geometry/Vector3DFormat.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/linear/BigMatrixImpl.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/linear/RealMatrixImpl.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/linear/RealVectorFormat.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/linear/RealVectorImpl.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/ContinuousOutputModel.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/optimization/DirectSearchOptimizer.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/random/EmpiricalDistributionImpl.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/random/ValueServer.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/util/DefaultTransformer.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/util/ResizableDoubleArray.java
    commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/linear/BigMatrixImplTest.java
    commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/util/TestBean.java

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/MessagesResources_fr.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/MessagesResources_fr.java?rev=712144&r1=712143&r2=712144&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/MessagesResources_fr.java
(original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/MessagesResources_fr.java
Fri Nov  7 06:55:23 2008
@@ -206,7 +206,61 @@
     { "empty selected row index array",
       "tableau des indices de lignes s\u00e9lectionn\u00e9es vide" },
     { "empty selected column index array",
-      "tableau des indices de colonnes s\u00e9lectionn\u00e9es vide" }
+      "tableau des indices de colonnes s\u00e9lectionn\u00e9es vide" },
+
+   // org.apache.commons.math.random.EmpiricalDistributionImpl
+   // org.apache.commons.math.random.ValueServer
+   { "URL {0} contains no data",
+     "l''adresse {0} ne contient aucune donn\u00e9e" },
+
+   // org.apache.commons.math.complex.ComplexFormat
+   { "unparseable complex number: \"{0}\"",
+     "\u00e9chec d''analyse du nombre complexe \"{0}\"" },
+
+   // org.apache.commons.math.fraction.FractionFormat
+   { "unparseable fraction number: \"{0}\"",
+     "\u00e9chec d''analyse du nombre rationnel \"{0}\"" },
+
+   // org.apache.commons.math.geometry.Vector3DFormat
+   { "unparseable 3D vector: \"{0}\"",
+     "\u00e9chec d''analyse du vecteur de dimension 3 \"{0}\"" },
+
+   // org.apache.commons.math.linear.RealVectorFormat
+   { "unparseable real vector: \"{0}\"",
+     "\u00e9chec d''analyse du vecteur r\u00e9el \"{0}\"" },
+
+   // org.apache.commons.math.util.ResizableDoubleArray
+   { "the index specified: {0} is larger than the current maximal index {1}",
+     "l''index sp\u00e9cifi\u00e9 ({0}) d\u00e9passe l''index maximal courant ({1})" },
+   { "elements cannot be retrieved from a negative array index {0}",
+     "impossible d''extraire un \u00e9l\u00e9ment \u00e0 un index n\u00e9gatif ({0})" },
+   { "cannot set an element at a negative index {0}",
+     "impossible de mettre un \u00e9l\u00e9ment \u00e0 un index n\u00e9gatif ({0})" },
+
+   // org.apache.commons.math.analysis.PolynomialFunctionLagrangeForm
+   { "identical abscissas x[{0}] == x[{1}] == {2} cause division by zero",
+     "division par z\u00e9ro caus\u00e9e par les abscisses identiques x[{0}] == x[{1}] ==
{2}" },
+
+   // org.apache.commons.math.fraction.Fraction
+   { "zero denominator in fraction {0}/{1}",
+     "d\u00e9nominateur null dans le nombre rationnel {0}/{1}" },
+   { "overflow in fraction {0}/{1}, cannot negate",
+     "d\u00e9passement de capacit\u00e9 pour la fraction {0}/{1}, son signe ne peut \u00eatre
chang\u00e9" },
+   { "overflow, numerator too large after multiply: {0}",
+     "d\u00e9passement de capacit\u00e9 pour le num\u00e9rateur apr\u00e8s multiplication
: {0}" },
+   { "the fraction to divide by must not be zero: {0}/{1}",
+     "division par un nombre rationnel nul : {0}/{1}" },
+
+   // org.apache.commons.math.geometry.Rotation
+   { "zero norm for rotation axis",
+     "norme nulle pour un axe de rotation" },
+
+   // org.apache.commons.math.geometry.Vector3D
+    // org.apache.commons.math.linear.RealVectorImpl
+   { "cannot normalize a zero norm vector",
+     "impossible de normer un vecteur de norme nulle" },
+   { "zero norm",
+     "norme nulle" }
 
   };
 

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/analysis/PolynomialFunctionLagrangeForm.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/analysis/PolynomialFunctionLagrangeForm.java?rev=712144&r1=712143&r2=712144&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/analysis/PolynomialFunctionLagrangeForm.java
(original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/analysis/PolynomialFunctionLagrangeForm.java
Fri Nov  7 06:55:23 2008
@@ -20,6 +20,7 @@
 
 import org.apache.commons.math.DuplicateSampleAbscissaException;
 import org.apache.commons.math.FunctionEvaluationException;
+import org.apache.commons.math.MathRuntimeException;
 
 /**
  * Implements the representation of a real polynomial function in
@@ -253,8 +254,14 @@
             }
             if (d == 0.0) {
                 // This happens only when two abscissas are identical.
-                throw new ArithmeticException
-                    ("Identical abscissas cause division by zero.");
+                for (int k = 0; k < n; ++k) {
+                    if ((i != k) && (x[i] == x[k])) {
+                        throw MathRuntimeException.createArithmeticException("identical abscissas
x[{0}] == x[{1}] == {2} cause division by zero",
+                                                                             new Object[]
{
+                                                                                 i, k, x[i]
+                                                                             });
+                    }
+                }
             }
             t = y[i] / d;
             // Lagrange polynomial is the sum of n terms, each of which is a

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/complex/ComplexFormat.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/complex/ComplexFormat.java?rev=712144&r1=712143&r2=712144&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/complex/ComplexFormat.java
(original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/complex/ComplexFormat.java
Fri Nov  7 06:55:23 2008
@@ -23,6 +23,7 @@
 import java.text.ParsePosition;
 import java.util.Locale;
 
+import org.apache.commons.math.MathRuntimeException;
 import org.apache.commons.math.util.CompositeFormat;
 
 /**
@@ -250,8 +251,9 @@
         ParsePosition parsePosition = new ParsePosition(0);
         Complex result = parse(source, parsePosition);
         if (parsePosition.getIndex() == 0) {
-            throw new ParseException("Unparseable complex number: \"" + source +
-                                     "\"", parsePosition.getErrorIndex());
+            throw MathRuntimeException.createParseException("unparseable complex number:
\"{0}\"",
+                                                            new Object[] { source },
+                                                            parsePosition.getErrorIndex());
         }
         return result;
     }

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/estimation/AbstractEstimator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/estimation/AbstractEstimator.java?rev=712144&r1=712143&r2=712144&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/estimation/AbstractEstimator.java
(original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/estimation/AbstractEstimator.java
Fri Nov  7 06:55:23 2008
@@ -182,7 +182,7 @@
             return ((RealMatrixImpl) new RealMatrixImpl(jTj, false).inverse()).getDataRef();
         } catch (InvalidMatrixException ime) {
             throw new EstimationException("unable to compute covariances: singular problem",
-                                          new Object[0]);
+                                          null);
         }
 
     }

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/estimation/GaussNewtonEstimator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/estimation/GaussNewtonEstimator.java?rev=712144&r1=712143&r2=712144&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/estimation/GaussNewtonEstimator.java
(original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/estimation/GaussNewtonEstimator.java
Fri Nov  7 06:55:23 2008
@@ -161,7 +161,7 @@
                 }
 
             } catch(InvalidMatrixException e) {
-                throw new EstimationException("unable to solve: singular problem", new Object[0]);
+                throw new EstimationException("unable to solve: singular problem", null);
             }
 
 

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/fraction/Fraction.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/fraction/Fraction.java?rev=712144&r1=712143&r2=712144&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/fraction/Fraction.java
(original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/fraction/Fraction.java
Fri Nov  7 06:55:23 2008
@@ -17,6 +17,8 @@
 package org.apache.commons.math.fraction;
 
 import java.math.BigInteger;
+
+import org.apache.commons.math.MathRuntimeException;
 import org.apache.commons.math.util.MathUtils;
 
 /**
@@ -200,12 +202,13 @@
     public Fraction(int num, int den) {
         super();
         if (den == 0) {
-            throw new ArithmeticException("The denominator must not be zero");
+            throw MathRuntimeException.createArithmeticException("zero denominator in fraction
{0}/{1}",
+                                                                 new Object[] { num, den});
         }
         if (den < 0) {
-            if (num == Integer.MIN_VALUE ||
-                    den == Integer.MIN_VALUE) {
-                throw new ArithmeticException("overflow: can't negate");
+            if (num == Integer.MIN_VALUE || den == Integer.MIN_VALUE) {
+                throw MathRuntimeException.createArithmeticException("overflow in fraction
{0}/{1}, cannot negate",
+                                                                     new Object[] { num,
den});
             }
             num = -num;
             den = -den;
@@ -361,7 +364,8 @@
      */
     public Fraction negate() {
         if (numerator==Integer.MIN_VALUE) {
-            throw new ArithmeticException("overflow: too large to negate");
+            throw MathRuntimeException.createArithmeticException("overflow in fraction {0}/{1},
cannot negate",
+                                                                 new Object[] { numerator,
denominator});
         }
         return new Fraction(-numerator, denominator);
     }
@@ -451,8 +455,8 @@
         // result is (t/d2) / (u'/d1)(v'/d2)
         BigInteger w = t.divide(BigInteger.valueOf(d2));
         if (w.bitLength() > 31) {
-            throw new ArithmeticException
-            ("overflow: numerator too large after multiply");
+            throw MathRuntimeException.createArithmeticException("overflow, numerator too
large after multiply: {0}",
+                                                                 new Object[] { w });
         }
         return new Fraction (w.intValue(), 
                 MathUtils.mulAndCheck(denominator/d1, 
@@ -500,7 +504,8 @@
             throw new IllegalArgumentException("The fraction must not be null");
         }
         if (fraction.numerator == 0) {
-            throw new ArithmeticException("The fraction to divide by must not be zero");
+            throw MathRuntimeException.createArithmeticException("the fraction to divide
by must not be zero: {0}/{1}",
+                                                                 new Object[] { fraction.numerator,
fraction.denominator });
         }
         return multiply(fraction.reciprocal());
     }
@@ -518,7 +523,8 @@
      */
     public static Fraction getReducedFraction(int numerator, int denominator) {
         if (denominator == 0) {
-            throw new ArithmeticException("The denominator must not be zero");
+            throw MathRuntimeException.createArithmeticException("zero denominator in fraction
{0}/{1}",
+                                                                 new Object[] { numerator,
denominator});
         }
         if (numerator==0) {
             return ZERO; // normalize zero.
@@ -530,7 +536,8 @@
         if (denominator < 0) {
             if (numerator==Integer.MIN_VALUE ||
                     denominator==Integer.MIN_VALUE) {
-                throw new ArithmeticException("overflow: can't negate");
+                throw MathRuntimeException.createArithmeticException("overflow in fraction
{0}/{1}, cannot negate",
+                                                                     new Object[] { numerator,
denominator});
             }
             numerator = -numerator;
             denominator = -denominator;

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/fraction/FractionFormat.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/fraction/FractionFormat.java?rev=712144&r1=712143&r2=712144&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/fraction/FractionFormat.java
(original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/fraction/FractionFormat.java
Fri Nov  7 06:55:23 2008
@@ -26,6 +26,7 @@
 import java.util.Locale;
 
 import org.apache.commons.math.ConvergenceException;
+import org.apache.commons.math.MathRuntimeException;
 
 /**
  * Formats a Fraction number in proper format or improper format.  The number
@@ -244,8 +245,9 @@
         ParsePosition parsePosition = new ParsePosition(0);
         Fraction result = parse(source, parsePosition);
         if (parsePosition.getIndex() == 0) {
-            throw new ParseException("Unparseable fraction number: \"" +
-                source + "\"", parsePosition.getErrorIndex());
+            throw MathRuntimeException.createParseException("unparseable fraction number:
\"{0}\"",
+                                                            new Object[] { source },
+                                                            parsePosition.getErrorIndex());
         }
         return result;
     }

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/geometry/Rotation.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/geometry/Rotation.java?rev=712144&r1=712143&r2=712144&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/geometry/Rotation.java
(original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/geometry/Rotation.java
Fri Nov  7 06:55:23 2008
@@ -19,6 +19,8 @@
 
 import java.io.Serializable;
 
+import org.apache.commons.math.MathRuntimeException;
+
 /**
  * This class implements rotations in a three-dimensional space.
  *
@@ -154,7 +156,8 @@
 
     double norm = axis.getNorm();
     if (norm == 0) {
-      throw new ArithmeticException("zero norm for rotation axis");
+      throw MathRuntimeException.createArithmeticException("zero norm for rotation axis",
+                                                           null);
     }
 
     double halfAngle = -0.5 * angle;

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/geometry/Vector3D.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/geometry/Vector3D.java?rev=712144&r1=712143&r2=712144&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/geometry/Vector3D.java
(original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/geometry/Vector3D.java
Fri Nov  7 06:55:23 2008
@@ -19,6 +19,7 @@
 
 import java.io.Serializable;
 
+import org.apache.commons.math.MathRuntimeException;
 import org.apache.commons.math.util.MathUtils;
 
 /** 
@@ -266,7 +267,8 @@
   public Vector3D normalize() {
     double s = getNorm();
     if (s == 0) {
-      throw new ArithmeticException("cannot normalize a zero norm vector");
+      throw MathRuntimeException.createArithmeticException("cannot normalize a zero norm
vector",
+                                                           null);
     }
     return scalarMultiply(1 / s);
   }
@@ -290,7 +292,7 @@
 
     double threshold = 0.6 * getNorm();
     if (threshold == 0) {
-      throw new ArithmeticException("null norm");
+      throw MathRuntimeException.createArithmeticException("zero norm", null);
     }
 
     if ((x >= -threshold) && (x <= threshold)) {
@@ -320,7 +322,7 @@
 
     double normProduct = v1.getNorm() * v2.getNorm();
     if (normProduct == 0) {
-      throw new ArithmeticException("null norm");
+      throw MathRuntimeException.createArithmeticException("zero norm", null);
     }
 
     double dot = dotProduct(v1, v2);

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/geometry/Vector3DFormat.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/geometry/Vector3DFormat.java?rev=712144&r1=712143&r2=712144&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/geometry/Vector3DFormat.java
(original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/geometry/Vector3DFormat.java
Fri Nov  7 06:55:23 2008
@@ -23,6 +23,7 @@
 import java.text.ParsePosition;
 import java.util.Locale;
 
+import org.apache.commons.math.MathRuntimeException;
 import org.apache.commons.math.util.CompositeFormat;
 
 /**
@@ -254,8 +255,9 @@
         ParsePosition parsePosition = new ParsePosition(0);
         Vector3D result = parse(source, parsePosition);
         if (parsePosition.getIndex() == 0) {
-            throw new ParseException("Unparseable 3D vector: \"" + source +
-                                     "\"", parsePosition.getErrorIndex());
+            throw MathRuntimeException.createParseException("unparseable 3D vector: \"{0}\"",
+                                                            new Object[] { source },
+                                                            parsePosition.getErrorIndex());
         }
         return result;
     }

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/linear/BigMatrixImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/linear/BigMatrixImpl.java?rev=712144&r1=712143&r2=712144&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/linear/BigMatrixImpl.java
(original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/linear/BigMatrixImpl.java
Fri Nov  7 06:55:23 2008
@@ -622,9 +622,9 @@
 
         if (selectedRows.length * selectedColumns.length == 0) {
             if (selectedRows.length == 0) {
-                throw new MatrixIndexException("empty selected row index array", new Object[0]);
+                throw new MatrixIndexException("empty selected row index array", null);
             }
-            throw new MatrixIndexException("empty selected column index array", new Object[0]);
+            throw new MatrixIndexException("empty selected column index array", null);
         }
 
         final BigDecimal[][] subMatrixData =

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/linear/RealMatrixImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/linear/RealMatrixImpl.java?rev=712144&r1=712143&r2=712144&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/linear/RealMatrixImpl.java
(original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/linear/RealMatrixImpl.java
Fri Nov  7 06:55:23 2008
@@ -413,9 +413,9 @@
 
         if (selectedRows.length * selectedColumns.length == 0) {
             if (selectedRows.length == 0) {
-                throw new MatrixIndexException("empty selected row index array", new Object[0]);
+                throw new MatrixIndexException("empty selected row index array", null);
             }
-            throw new MatrixIndexException("empty selected column index array", new Object[0]);
+            throw new MatrixIndexException("empty selected column index array", null);
         }
 
         final double[][] subMatrixData =

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/linear/RealVectorFormat.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/linear/RealVectorFormat.java?rev=712144&r1=712143&r2=712144&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/linear/RealVectorFormat.java
(original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/linear/RealVectorFormat.java
Fri Nov  7 06:55:23 2008
@@ -25,6 +25,7 @@
 import java.util.List;
 import java.util.Locale;
 
+import org.apache.commons.math.MathRuntimeException;
 import org.apache.commons.math.util.CompositeFormat;
 
 /**
@@ -258,8 +259,9 @@
         ParsePosition parsePosition = new ParsePosition(0);
         RealVectorImpl result = parse(source, parsePosition);
         if (parsePosition.getIndex() == 0) {
-            throw new ParseException("Unparseable real vector: \"" + source +
-                                     "\"", parsePosition.getErrorIndex());
+            throw MathRuntimeException.createParseException("unparseable real vector: \"{0}\"",
+                                                            new Object[] { source },
+                                                            parsePosition.getErrorIndex());
         }
         return result;
     }

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/linear/RealVectorImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/linear/RealVectorImpl.java?rev=712144&r1=712143&r2=712144&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/linear/RealVectorImpl.java
(original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/linear/RealVectorImpl.java
Fri Nov  7 06:55:23 2008
@@ -19,6 +19,7 @@
 import java.io.Serializable;
 import java.util.Arrays;
 
+import org.apache.commons.math.MathRuntimeException;
 import org.apache.commons.math.util.MathUtils;
 
 /**
@@ -1068,7 +1069,7 @@
     public RealVector unitVector() throws ArithmeticException {
         final double norm = getNorm();
         if (norm == 0) {
-            throw new ArithmeticException("null norm");
+            throw MathRuntimeException.createArithmeticException("zero norm", null);
         }
         return mapDivide(getNorm());
     }
@@ -1077,7 +1078,8 @@
     public void unitize() throws ArithmeticException {
         final double norm = getNorm();
         if (norm == 0) {
-            throw new ArithmeticException("null norm");
+            throw MathRuntimeException.createArithmeticException("cannot normalize a zero
norm vector",
+                                                                 null);
         }
         for (int i = 0; i < data.length; i++) {
             data[i] /= norm;

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/ContinuousOutputModel.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/ContinuousOutputModel.java?rev=712144&r1=712143&r2=712144&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/ContinuousOutputModel.java
(original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/ContinuousOutputModel.java
Fri Nov  7 06:55:23 2008
@@ -315,7 +315,7 @@
       steps.get(index).setInterpolatedTime(time);
 
     } catch (DerivativeException de) {
-      throw new MathRuntimeException("unexpected exception caught", new Object[0], de);
+      throw new MathRuntimeException("unexpected exception caught", null, de);
     }
 
   }

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/optimization/DirectSearchOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/optimization/DirectSearchOptimizer.java?rev=712144&r1=712143&r2=712144&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/optimization/DirectSearchOptimizer.java
(original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/optimization/DirectSearchOptimizer.java
Fri Nov  7 06:55:23 2008
@@ -270,7 +270,7 @@
 
         } catch (DimensionMismatchException dme) {
             // this should not happen
-            throw new MathRuntimeException("unexpected exception caught", new Object[0],
dme);
+            throw new MathRuntimeException("unexpected exception caught", null, dme);
         }
 
     }

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/random/EmpiricalDistributionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/random/EmpiricalDistributionImpl.java?rev=712144&r1=712143&r2=712144&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/random/EmpiricalDistributionImpl.java
(original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/random/EmpiricalDistributionImpl.java
Fri Nov  7 06:55:23 2008
@@ -18,7 +18,6 @@
 package org.apache.commons.math.random;
 
 import java.io.BufferedReader;
-import java.io.EOFException;
 import java.io.File;
 import java.io.FileReader;
 import java.io.IOException;
@@ -130,11 +129,18 @@
             DataAdapter da = new StreamDataAdapter(in);
             try {
                 da.computeStats();
+            } catch (IOException ioe) {
+                // don't wrap exceptions which are already IOException
+                throw ioe;
+            } catch (RuntimeException rte) {
+                // don't wrap RuntimeExceptions
+                throw rte;
             } catch (Exception e) {
                 throw new IOException(e.getMessage());
             }
             if (sampleStats.getN() == 0) {
-                throw new EOFException("URL " + url + " contains no data");
+                throw MathRuntimeException.createEOFException("URL {0} contains no data",
+                                                              new Object[] { url });
             }
             in = new BufferedReader(new InputStreamReader(url.openStream()));
             fillBinStats(in);
@@ -162,6 +168,12 @@
             DataAdapter da = new StreamDataAdapter(in);
             try {
                 da.computeStats();
+            } catch (IOException ioe) {
+                // don't wrap exceptions which are already IOException
+                throw ioe;
+            } catch (RuntimeException rte) {
+                // don't wrap RuntimeExceptions
+                throw rte;
             } catch (Exception e) {
                 throw new IOException(e.getMessage());
             }
@@ -357,12 +369,14 @@
         DataAdapter da = aFactory.getAdapter(in);
         try {
             da.computeBinStats(min, delta);
+        } catch (IOException ioe) {
+            // don't wrap exceptions which are already IOException
+            throw ioe;
+        } catch (RuntimeException rte) {
+            // don't wrap RuntimeExceptions
+            throw rte;
         } catch (Exception e) {
-            if(e instanceof RuntimeException){
-                throw new RuntimeException(e.getMessage());
-            }else{
-                throw new IOException(e.getMessage());
-            }
+            throw new IOException(e.getMessage());
         }
 
         // Assign upperBounds based on bin counts
@@ -419,7 +433,7 @@
                }
            }
         }
-        throw new MathRuntimeException("no bin selected", new Object[0]);
+        throw new MathRuntimeException("no bin selected", null);
     }
 
     /**

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/random/ValueServer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/random/ValueServer.java?rev=712144&r1=712143&r2=712144&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/random/ValueServer.java
(original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/random/ValueServer.java
Fri Nov  7 06:55:23 2008
@@ -17,11 +17,12 @@
 
 package org.apache.commons.math.random;
 import java.io.BufferedReader;
-import java.io.EOFException;
-import java.io.InputStreamReader;
 import java.io.IOException;
-import java.net.URL;
+import java.io.InputStreamReader;
 import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.apache.commons.math.MathRuntimeException;
 
 /**
  * Generates values for use in simulation applications.
@@ -328,7 +329,8 @@
             closeReplayFile();
             resetReplayFile();
             if ((str = filePointer.readLine()) == null) {
-                throw new EOFException("URL " + valuesFileURL + " contains no data");
+                throw MathRuntimeException.createEOFException("URL {0} contains no data",
+                                                              new Object[] { valuesFileURL
});
             }
         }
         return Double.valueOf(str).doubleValue();

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/util/DefaultTransformer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/util/DefaultTransformer.java?rev=712144&r1=712143&r2=712144&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/util/DefaultTransformer.java
(original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/util/DefaultTransformer.java
Fri Nov  7 06:55:23 2008
@@ -44,7 +44,7 @@
     public double transform(Object o) throws MathException{
 
         if (o == null) {
-            throw new MathException("Conversion Exception in Transformation, Object is null",
new Object[0]);
+            throw new MathException("Conversion Exception in Transformation, Object is null",
null);
         }
 
         if (o instanceof Number) {

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/util/ResizableDoubleArray.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/util/ResizableDoubleArray.java?rev=712144&r1=712143&r2=712144&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/util/ResizableDoubleArray.java
(original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/util/ResizableDoubleArray.java
Fri Nov  7 06:55:23 2008
@@ -18,6 +18,8 @@
 
 import java.io.Serializable;
 
+import org.apache.commons.math.MathRuntimeException;
+
 /**
  * <p>
  * A variable length {@link DoubleArray} implementation that automatically 
@@ -454,16 +456,13 @@
      */
     public synchronized double getElement(int index) {
         if (index >= numElements) {
-            String msg =
-                "The index specified: " + index +
-                " is larger than the current number of elements";
-            throw new ArrayIndexOutOfBoundsException(msg);
+            throw MathRuntimeException.createArrayIndexOutOfBoundsException("the index specified:
{0} is larger than the current maximal index {1}",
+                                                                            new Object[]
{ index, numElements - 1 });
         } else if (index >= 0) {
             return internalArray[startIndex + index];
         } else {
-            String msg =
-                "Elements cannot be retrieved from a negative array index";
-            throw new ArrayIndexOutOfBoundsException(msg);
+            throw MathRuntimeException.createArrayIndexOutOfBoundsException("elements cannot
be retrieved from a negative array index {0}",
+                                                                            new Object[]
{ index });
         }
     }
     
@@ -570,8 +569,8 @@
      */
     public synchronized void setElement(int index, double value) {
         if (index < 0) {
-            String msg = "Cannot set an element at a negative index";
-            throw new ArrayIndexOutOfBoundsException(msg);
+            throw MathRuntimeException.createArrayIndexOutOfBoundsException("cannot set an
element at a negative index {0}",
+                                                                            new Object[]
{ index });
         }
         if (index + 1 > numElements) {
             numElements = index + 1;

Modified: commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/linear/BigMatrixImplTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/linear/BigMatrixImplTest.java?rev=712144&r1=712143&r2=712144&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/linear/BigMatrixImplTest.java
(original)
+++ commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/linear/BigMatrixImplTest.java
Fri Nov  7 06:55:23 2008
@@ -783,7 +783,7 @@
         if (!lu.isSquare() || lowerData.length != lowerData[0].length || upperData.length
!= upperData[0].length ||
                 lowerData.length != upperData.length
                 || lowerData.length != lu.getRowDimension()) {
-            throw new InvalidMatrixException("incorrect dimensions", new Object[0]);
+            throw new InvalidMatrixException("incorrect dimensions", null);
         }    
         int n = lu.getRowDimension();
         for (int i = 0; i < n; i++) {

Modified: commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/util/TestBean.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/util/TestBean.java?rev=712144&r1=712143&r2=712144&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/util/TestBean.java
(original)
+++ commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/util/TestBean.java
Fri Nov  7 06:55:23 2008
@@ -59,7 +59,7 @@
      * 
      */
     public Double getZ() {
-        throw new MathRuntimeException();
+        throw new MathRuntimeException("?", null);
     }
 
     /**



Mime
View raw message