commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r955423 [1/6] - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math/ main/java/org/apache/commons/math/analysis/integration/ main/java/org/apache/commons/math/analysis/interpolation/ main/java/org/apache/commons/math/analys...
Date Wed, 16 Jun 2010 23:03:42 GMT
Author: luc
Date: Wed Jun 16 23:03:38 2010
New Revision: 955423

URL: http://svn.apache.org/viewvc?rev=955423&view=rev
Log:
changed the localization mechanism for error messages. The new system is based on an enum rather than on duplicated string literals.
JIRA: MATH-361

Added:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/DummyLocalizable.java   (with props)
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/Localizable.java   (with props)
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/LocalizedFormats.java   (with props)
    commons/proper/math/trunk/src/main/resources/META-INF/
    commons/proper/math/trunk/src/main/resources/META-INF/localization/
    commons/proper/math/trunk/src/main/resources/META-INF/localization/LocalizedFormats_fr.properties   (with props)
Removed:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/MessagesResources_fr.java
Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/ConvergenceException.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/DimensionMismatchException.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/DuplicateSampleAbscissaException.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/FunctionEvaluationException.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/MathConfigurationException.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/MathException.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/MathRuntimeException.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/MaxEvaluationsExceededException.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/MaxIterationsExceededException.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/RombergIntegrator.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/SimpsonIntegrator.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/TrapezoidIntegrator.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/UnivariateRealIntegratorImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/BicubicSplineInterpolatingFunction.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/BicubicSplineInterpolator.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/LoessInterpolator.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/MicrosphereInterpolatingFunction.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/MicrosphereInterpolator.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/SmoothingBicubicSplineInterpolator.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/SmoothingPolynomialBicubicSplineInterpolator.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/SplineInterpolator.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/TricubicSplineInterpolatingFunction.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/TricubicSplineInterpolator.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialFunction.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialFunctionLagrangeForm.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialFunctionNewtonForm.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialSplineFunction.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/BrentSolver.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/LaguerreSolver.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/NewtonSolver.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/SecantSolver.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/UnivariateRealSolverImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/UnivariateRealSolverUtils.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/complex/Complex.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/complex/ComplexFormat.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/complex/ComplexUtils.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/AbstractContinuousDistribution.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/AbstractDistribution.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/AbstractIntegerDistribution.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/BinomialDistributionImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/CauchyDistributionImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ExponentialDistributionImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/FDistributionImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/GammaDistributionImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/HypergeometricDistributionImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/NormalDistributionImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PascalDistributionImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PoissonDistributionImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/TDistributionImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/WeibullDistributionImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ZipfDistributionImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/estimation/AbstractEstimator.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/estimation/EstimationException.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/estimation/GaussNewtonEstimator.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/estimation/LevenbergMarquardtEstimator.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/fraction/AbstractFormat.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/fraction/BigFraction.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/fraction/BigFractionFormat.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/fraction/Fraction.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/fraction/FractionConversionException.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/fraction/FractionFormat.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/fraction/ProperBigFractionFormat.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/fraction/ProperFractionFormat.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/geometry/CardanEulerSingularityException.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/geometry/NotARotationMatrixException.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/geometry/Rotation.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/geometry/Vector3D.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/geometry/Vector3DFormat.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/AbstractFieldMatrix.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/AbstractRealMatrix.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/AbstractRealVector.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/Array2DRowFieldMatrix.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/Array2DRowRealMatrix.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/ArrayFieldVector.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/ArrayRealVector.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/BigMatrixImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/BlockFieldMatrix.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/BlockRealMatrix.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/CholeskyDecompositionImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/EigenDecompositionImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/FieldLUDecompositionImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/InvalidMatrixException.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/LUDecompositionImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/MatrixIndexException.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/MatrixUtils.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/MatrixVisitorException.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/NonSquareMatrixException.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/NotPositiveDefiniteMatrixException.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/NotSymmetricMatrixException.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/OpenMapRealVector.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/QRDecompositionImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/RealMatrixImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/RealVectorFormat.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/SingularMatrixException.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/SingularValueDecompositionImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/SparseFieldVector.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/AbstractIntegrator.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/ContinuousOutputModel.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/DerivativeException.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/IntegratorException.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/MultistepIntegrator.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/events/EventException.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/jacobians/FirstOrderIntegratorWithJacobians.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/AdaptiveStepsizeIntegrator.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/LeastSquaresConverter.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/MultiStartDifferentiableMultivariateRealOptimizer.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/MultiStartDifferentiableMultivariateVectorialOptimizer.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/MultiStartMultivariateRealOptimizer.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/MultiStartUnivariateRealOptimizer.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/OptimizationException.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/direct/DirectSearchOptimizer.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/fitting/HarmonicCoefficientsGuesser.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/fitting/HarmonicFitter.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/AbstractLeastSquaresOptimizer.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizer.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizer.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/NonLinearConjugateGradientOptimizer.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/linear/NoFeasibleSolutionException.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/linear/UnboundedSolutionException.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/univariate/AbstractUnivariateRealOptimizer.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/AbstractRandomGenerator.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/BitsStreamGenerator.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/EmpiricalDistributionImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/RandomDataImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/UncorrelatedRandomVectorGenerator.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/ValueServer.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/Frequency.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/StatUtils.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/correlation/Covariance.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/correlation/PearsonsCorrelation.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/correlation/SpearmansCorrelation.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/AbstractStorelessUnivariateStatistic.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/AbstractUnivariateStatistic.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/DescriptiveStatistics.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/MultivariateSummaryStatistics.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/SummaryStatistics.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/GeometricMean.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/Kurtosis.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/SemiVariance.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/Variance.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/rank/Percentile.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/inference/ChiSquareTestImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/inference/OneWayAnovaImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/inference/TTestImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/regression/AbstractMultipleLinearRegression.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/regression/SimpleRegression.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastCosineTransformer.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastFourierTransformer.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastHadamardTransformer.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastSineTransformer.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/ContinuedFraction.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/DefaultTransformer.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/OpenIntToDoubleHashMap.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/OpenIntToFieldHashMap.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/ResizableDoubleArray.java
    commons/proper/math/trunk/src/site/xdoc/changes.xml
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/ConvergenceExceptionTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/FunctionEvaluationExceptionTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/MathConfigurationExceptionTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/MathExceptionTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/MaxIterationsExceededExceptionTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/HighamHall54IntegratorTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/TestBean.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/ConvergenceException.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/ConvergenceException.java?rev=955423&r1=955422&r2=955423&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/ConvergenceException.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/ConvergenceException.java Wed Jun 16 23:03:38 2010
@@ -16,6 +16,10 @@
  */
 package org.apache.commons.math;
 
+import org.apache.commons.math.util.DummyLocalizable;
+import org.apache.commons.math.util.Localizable;
+import org.apache.commons.math.util.LocalizedFormats;
+
 /**
  * Error thrown when a numerical computation can not be performed because the
  * numerical result failed to converge to a finite value.
@@ -25,13 +29,13 @@ package org.apache.commons.math;
 public class ConvergenceException extends MathException {
 
     /** Serializable version identifier */
-    private static final long serialVersionUID = 4883703247677159141L;
+    private static final long serialVersionUID = -1111352570797662604L;
 
     /**
      * Default constructor.
      */
     public ConvergenceException() {
-        super("Convergence failed");
+        super(LocalizedFormats.CONVERGENCE_FAILED);
     }
 
     /**
@@ -40,8 +44,21 @@ public class ConvergenceException extend
      * @param pattern format specifier
      * @param arguments format arguments
      * @since 1.2
+     * @deprecated as of 2.2 replaced by {@link #ConvergenceException(Localizable, Object...)}
      */
+    @Deprecated
     public ConvergenceException(String pattern, Object ... arguments) {
+        this(new DummyLocalizable(pattern), arguments);
+    }
+
+    /**
+     * Constructs an exception with specified formatted detail message.
+     * Message formatting is delegated to {@link java.text.MessageFormat}.
+     * @param pattern format specifier
+     * @param arguments format arguments
+     * @since 2.2
+     */
+    public ConvergenceException(Localizable pattern, Object ... arguments) {
         super(pattern, arguments);
     }
 
@@ -60,8 +77,22 @@ public class ConvergenceException extend
      * @param pattern format specifier
      * @param arguments format arguments
      * @since 1.2
+     * @deprecated as of 2.2 replaced by {@link #ConvergenceException(Throwable, Localizable, Object...)}
      */
+    @Deprecated
     public ConvergenceException(Throwable cause, String pattern, Object ... arguments) {
+        this(cause, new DummyLocalizable(pattern), arguments);
+    }
+
+    /**
+     * Constructs an exception with specified formatted detail message and root cause.
+     * Message formatting is delegated to {@link java.text.MessageFormat}.
+     * @param cause  the exception or error that caused this exception to be thrown
+     * @param pattern format specifier
+     * @param arguments format arguments
+     * @since 2.2
+     */
+    public ConvergenceException(Throwable cause, Localizable pattern, Object ... arguments) {
         super(cause, pattern, arguments);
     }
 

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/DimensionMismatchException.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/DimensionMismatchException.java?rev=955423&r1=955422&r2=955423&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/DimensionMismatchException.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/DimensionMismatchException.java Wed Jun 16 23:03:38 2010
@@ -16,6 +16,8 @@
  */
 package org.apache.commons.math;
 
+import org.apache.commons.math.util.LocalizedFormats;
+
 /**
  * Error thrown when two dimensions differ.
  *
@@ -39,7 +41,7 @@ public class DimensionMismatchException 
      * @param dimension2 second dimension
      */
     public DimensionMismatchException(final int dimension1, final int dimension2) {
-        super("dimension mismatch {0} != {1}", dimension1, dimension2);
+        super(LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE, dimension1, dimension2);
         this.dimension1 = dimension1;
         this.dimension2 = dimension2;
     }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/DuplicateSampleAbscissaException.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/DuplicateSampleAbscissaException.java?rev=955423&r1=955422&r2=955423&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/DuplicateSampleAbscissaException.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/DuplicateSampleAbscissaException.java Wed Jun 16 23:03:38 2010
@@ -16,6 +16,8 @@
  */
 package org.apache.commons.math;
 
+import org.apache.commons.math.util.LocalizedFormats;
+
 /**
  * Exception thrown when a sample contains several entries at the same abscissa.
  *
@@ -34,7 +36,7 @@ public class DuplicateSampleAbscissaExce
      * @param i2 index of another entry having the duplicate abscissa
      */
     public DuplicateSampleAbscissaException(double abscissa, int i1, int i2) {
-        super("Abscissa {0} is duplicated at both indices {1} and {2}",
+        super(LocalizedFormats.DUPLICATED_ABSCISSA,
               abscissa, i1, i2);
     }
 

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/FunctionEvaluationException.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/FunctionEvaluationException.java?rev=955423&r1=955422&r2=955423&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/FunctionEvaluationException.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/FunctionEvaluationException.java Wed Jun 16 23:03:38 2010
@@ -17,6 +17,9 @@
 package org.apache.commons.math;
 
 import org.apache.commons.math.linear.ArrayRealVector;
+import org.apache.commons.math.util.DummyLocalizable;
+import org.apache.commons.math.util.Localizable;
+import org.apache.commons.math.util.LocalizedFormats;
 
 /**
  * Exception thrown when an error occurs evaluating a function.
@@ -29,11 +32,7 @@ import org.apache.commons.math.linear.Ar
 public class FunctionEvaluationException extends MathException  {
 
     /** Serializable version identifier. */
-    private static final long serialVersionUID = -4305020489115478365L;
-
-    /** Message for failed evaluation. */
-    private static final String FAILED_EVALUATION_MESSAGE =
-        "evaluation failed for argument = {0}";
+    private static final long serialVersionUID = 1384427981840836868L;
 
     /** Argument causing function evaluation failure */
     private double[] argument;
@@ -45,7 +44,7 @@ public class FunctionEvaluationException
      * @param argument  the failing function argument
      */
     public FunctionEvaluationException(double argument) {
-        super(FAILED_EVALUATION_MESSAGE, argument);
+        super(LocalizedFormats.EVALUATION_FAILED, argument);
         this.argument = new double[] { argument };
     }
 
@@ -57,7 +56,7 @@ public class FunctionEvaluationException
      * @since 2.0
      */
     public FunctionEvaluationException(double[] argument) {
-        super(FAILED_EVALUATION_MESSAGE, new ArrayRealVector(argument));
+        super(LocalizedFormats.EVALUATION_FAILED, new ArrayRealVector(argument));
         this.argument = argument.clone();
     }
 
@@ -71,6 +70,19 @@ public class FunctionEvaluationException
      */
     public FunctionEvaluationException(double argument,
                                        String pattern, Object ... arguments) {
+        this(argument, new DummyLocalizable(pattern), argument);
+    }
+
+    /**
+     * Constructs an exception with specified formatted detail message.
+     * Message formatting is delegated to {@link java.text.MessageFormat}.
+     * @param argument  the failing function argument
+     * @param pattern format specifier
+     * @param arguments format arguments
+     * @since 2.2
+     */
+    public FunctionEvaluationException(double argument,
+                                       Localizable pattern, Object ... arguments) {
         super(pattern, arguments);
         this.argument = new double[] { argument };
     }
@@ -85,6 +97,19 @@ public class FunctionEvaluationException
      */
     public FunctionEvaluationException(double[] argument,
                                        String pattern, Object ... arguments) {
+        this(argument, new DummyLocalizable(pattern), argument);
+    }
+
+    /**
+     * Constructs an exception with specified formatted detail message.
+     * Message formatting is delegated to {@link java.text.MessageFormat}.
+     * @param argument  the failing function argument
+     * @param pattern format specifier
+     * @param arguments format arguments
+     * @since 2.2
+     */
+    public FunctionEvaluationException(double[] argument,
+                                       Localizable pattern, Object ... arguments) {
         super(pattern, arguments);
         this.argument = argument.clone();
     }
@@ -125,6 +150,21 @@ public class FunctionEvaluationException
     public FunctionEvaluationException(Throwable cause,
                                        double argument, String pattern,
                                        Object ... arguments) {
+        this(cause, argument, new DummyLocalizable(pattern), argument);
+    }
+
+    /**
+     * Constructs an exception with specified formatted detail message and root cause.
+     * Message formatting is delegated to {@link java.text.MessageFormat}.
+     * @param cause  the exception or error that caused this exception to be thrown
+     * @param argument  the failing function argument
+     * @param pattern format specifier
+     * @param arguments format arguments
+     * @since 2.2
+     */
+    public FunctionEvaluationException(Throwable cause,
+                                       double argument, Localizable pattern,
+                                       Object ... arguments) {
         super(cause, pattern, arguments);
         this.argument = new double[] { argument };
     }
@@ -141,6 +181,21 @@ public class FunctionEvaluationException
     public FunctionEvaluationException(Throwable cause,
                                        double[] argument, String pattern,
                                        Object ... arguments) {
+        this(cause, argument, new DummyLocalizable(pattern), argument);
+    }
+
+    /**
+     * Constructs an exception with specified formatted detail message and root cause.
+     * Message formatting is delegated to {@link java.text.MessageFormat}.
+     * @param cause  the exception or error that caused this exception to be thrown
+     * @param argument  the failing function argument
+     * @param pattern format specifier
+     * @param arguments format arguments
+     * @since 2.2
+     */
+    public FunctionEvaluationException(Throwable cause,
+                                       double[] argument, Localizable pattern,
+                                       Object ... arguments) {
         super(cause, pattern, arguments);
         this.argument = argument.clone();
     }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/MathConfigurationException.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/MathConfigurationException.java?rev=955423&r1=955422&r2=955423&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/MathConfigurationException.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/MathConfigurationException.java Wed Jun 16 23:03:38 2010
@@ -18,6 +18,9 @@ package org.apache.commons.math;
 
 import java.io.Serializable;
 
+import org.apache.commons.math.util.DummyLocalizable;
+import org.apache.commons.math.util.Localizable;
+
 /**
  * Signals a configuration problem with any of the factory methods.
  * @version $Revision$ $Date$
@@ -42,6 +45,17 @@ public class MathConfigurationException 
      * @since 1.2
      */
     public MathConfigurationException(String pattern, Object ... arguments) {
+        this(new DummyLocalizable(pattern), arguments);
+    }
+
+    /**
+     * Constructs an exception with specified formatted detail message.
+     * Message formatting is delegated to {@link java.text.MessageFormat}.
+     * @param pattern format specifier
+     * @param arguments format arguments
+     * @since 2.2
+     */
+    public MathConfigurationException(Localizable pattern, Object ... arguments) {
         super(pattern, arguments);
     }
 
@@ -62,6 +76,18 @@ public class MathConfigurationException 
      * @since 1.2
      */
     public MathConfigurationException(Throwable cause, String pattern, Object ... arguments) {
+        this(cause, new DummyLocalizable(pattern), arguments);
+    }
+
+    /**
+     * Constructs an exception with specified formatted detail message and root cause.
+     * Message formatting is delegated to {@link java.text.MessageFormat}.
+     * @param cause  the exception or error that caused this exception to be thrown
+     * @param pattern format specifier
+     * @param arguments format arguments
+     * @since 2.2
+     */
+    public MathConfigurationException(Throwable cause, Localizable pattern, Object ... arguments) {
         super(cause, pattern, arguments);
     }
 

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/MathException.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/MathException.java?rev=955423&r1=955422&r2=955423&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/MathException.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/MathException.java Wed Jun 16 23:03:38 2010
@@ -20,8 +20,10 @@ import java.io.PrintStream;
 import java.io.PrintWriter;
 import java.text.MessageFormat;
 import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
+
+import org.apache.commons.math.util.DummyLocalizable;
+import org.apache.commons.math.util.Localizable;
+import org.apache.commons.math.util.LocalizedFormats;
 
 
 /**
@@ -36,12 +38,12 @@ import java.util.ResourceBundle;
 public class MathException extends Exception {
 
     /** Serializable version identifier. */
-    private static final long serialVersionUID = -9004610152740737812L;
+    private static final long serialVersionUID = 7428019509644517071L;
 
     /**
      * Pattern used to build the message.
      */
-    private final String pattern;
+    private final Localizable pattern;
 
     /**
      * Arguments used to build the message.
@@ -53,8 +55,8 @@ public class MathException extends Excep
      * detail message.
      */
     public MathException() {
-        this.pattern   = null;
-        this.arguments = new Object[0];
+        this.pattern   = LocalizedFormats.SIMPLE_MESSAGE;
+        this.arguments = new Object[] { "" };
     }
 
     /**
@@ -63,8 +65,21 @@ public class MathException extends Excep
      * Message formatting is delegated to {@link java.text.MessageFormat}.
      * @param pattern format specifier
      * @param arguments format arguments
+     * @deprecated as of 2.2 replaced by {@link #MathException(Localizable, Object...)}
      */
+    @Deprecated
     public MathException(String pattern, Object ... arguments) {
+      this(new DummyLocalizable(pattern), arguments);
+    }
+
+    /**
+     * Constructs a new <code>MathException</code> with specified
+     * formatted detail message.
+     * Message formatting is delegated to {@link java.text.MessageFormat}.
+     * @param pattern format specifier
+     * @param arguments format arguments
+     */
+    public MathException(Localizable pattern, Object ... arguments) {
       this.pattern   = pattern;
       this.arguments = (arguments == null) ? new Object[0] : arguments.clone();
     }
@@ -78,8 +93,8 @@ public class MathException extends Excep
      */
     public MathException(Throwable rootCause) {
         super(rootCause);
-        this.pattern   = getMessage();
-        this.arguments = new Object[0];
+        this.pattern   = LocalizedFormats.SIMPLE_MESSAGE;
+        this.arguments = new Object[] { (rootCause == null) ? "" : rootCause.getMessage() };
     }
 
     /**
@@ -91,45 +106,46 @@ public class MathException extends Excep
      * @param pattern format specifier
      * @param arguments format arguments
      * @since 1.2
+     * @deprecated as of 2.2 replaced by {@link #MathException(Throwable, Localizable, Object...)}
      */
+    @Deprecated
     public MathException(Throwable rootCause, String pattern, Object ... arguments) {
-      super(rootCause);
-      this.pattern   = pattern;
-      this.arguments = (arguments == null) ? new Object[0] : arguments.clone();
+        this(rootCause, new DummyLocalizable(pattern), arguments);
     }
 
     /**
-     * Translate a string to a given locale.
-     * @param s string to translate
-     * @param locale locale into which to translate the string
-     * @return translated string or original string
-     * for unsupported locales or unknown strings
-     */
-    private static String translate(String s, Locale locale) {
-        try {
-            ResourceBundle bundle =
-                    ResourceBundle.getBundle("org.apache.commons.math.MessagesResources", locale);
-            if (bundle.getLocale().getLanguage().equals(locale.getLanguage())) {
-                // the value of the resource is the translated string
-                return bundle.getString(s);
-            }
-
-        } catch (MissingResourceException mre) {
-            // do nothing here
-        }
-
-        // the locale is not supported or the resource is unknown
-        // don't translate and fall back to using the string as is
-        return s;
-
+     * Constructs a new <code>MathException</code> with specified
+     * formatted detail message and nested <code>Throwable</code> root cause.
+     * Message formatting is delegated to {@link java.text.MessageFormat}.
+     * @param rootCause the exception or error that caused this exception
+     * to be thrown.
+     * @param pattern format specifier
+     * @param arguments format arguments
+     * @since 1.2
+     */
+    public MathException(Throwable rootCause, Localizable pattern, Object ... arguments) {
+      super(rootCause);
+      this.pattern   = pattern;
+      this.arguments = (arguments == null) ? new Object[0] : arguments.clone();
     }
 
     /** Gets the pattern used to build the message of this throwable.
      *
      * @return the pattern used to build the message of this throwable
      * @since 1.2
+     * @deprecated as of 2.2 replaced by {@link #getLocalizablePattern()}
      */
+    @Deprecated
     public String getPattern() {
+        return pattern.getSourceString();
+    }
+
+    /** Gets the localizable pattern used to build the message of this throwable.
+     *
+     * @return the localizable pattern used to build the message of this throwable
+     * @since 2.2
+     */
+    public Localizable getLocalizablePattern() {
         return pattern;
     }
 
@@ -150,7 +166,10 @@ public class MathException extends Excep
      * @since 1.2
      */
     public String getMessage(final Locale locale) {
-        return (pattern == null) ? "" : new MessageFormat(translate(pattern, locale), locale).format(arguments);
+        if (pattern != null) {
+            return new MessageFormat(pattern.getLocalizedString(locale), locale).format(arguments);
+        }
+        return "";
     }
 
     /** {@inheritDoc} */

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/MathRuntimeException.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/MathRuntimeException.java?rev=955423&r1=955422&r2=955423&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/MathRuntimeException.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/MathRuntimeException.java Wed Jun 16 23:03:38 2010
@@ -24,9 +24,11 @@ import java.text.MessageFormat;
 import java.text.ParseException;
 import java.util.ConcurrentModificationException;
 import java.util.Locale;
-import java.util.MissingResourceException;
 import java.util.NoSuchElementException;
-import java.util.ResourceBundle;
+
+import org.apache.commons.math.util.DummyLocalizable;
+import org.apache.commons.math.util.Localizable;
+import org.apache.commons.math.util.LocalizedFormats;
 
 /**
 * Base class for commons-math unchecked exceptions.
@@ -37,12 +39,12 @@ import java.util.ResourceBundle;
 public class MathRuntimeException extends RuntimeException {
 
     /** Serializable version identifier. */
-    private static final long serialVersionUID = -5128983364075381060L;
+    private static final long serialVersionUID = 9058794795027570002L;
 
     /**
      * Pattern used to build the message.
      */
-    private final String pattern;
+    private final Localizable pattern;
 
     /**
      * Arguments used to build the message.
@@ -55,8 +57,22 @@ public class MathRuntimeException extend
      * Message formatting is delegated to {@link java.text.MessageFormat}.
      * @param pattern format specifier
      * @param arguments format arguments
+     * @deprecated as of 2.2 replaced by {@link #MathRuntimeException(Localizable, Object...)}
      */
+    @Deprecated
     public MathRuntimeException(final String pattern, final Object ... arguments) {
+        this(new DummyLocalizable(pattern), arguments);
+    }
+
+    /**
+     * Constructs a new <code>MathRuntimeException</code> with specified
+     * formatted detail message.
+     * Message formatting is delegated to {@link java.text.MessageFormat}.
+     * @param pattern format specifier
+     * @param arguments format arguments
+     * @since 2.2
+     */
+    public MathRuntimeException(final Localizable pattern, final Object ... arguments) {
         this.pattern   = pattern;
         this.arguments = (arguments == null) ? new Object[0] : arguments.clone();
     }
@@ -70,8 +86,8 @@ public class MathRuntimeException extend
      */
     public MathRuntimeException(final Throwable rootCause) {
         super(rootCause);
-        this.pattern   = getMessage();
-        this.arguments = new Object[0];
+        this.pattern   = LocalizedFormats.SIMPLE_MESSAGE;
+        this.arguments = new Object[] { (rootCause == null) ? "" : rootCause.getMessage() };
     }
 
     /**
@@ -82,38 +98,29 @@ public class MathRuntimeException extend
      * to be thrown.
      * @param pattern format specifier
      * @param arguments format arguments
+     * @deprecated as of 2.2 replaced by {@link #MathRuntimeException(Throwable, Localizable, Object...)}
      */
+    @Deprecated
     public MathRuntimeException(final Throwable rootCause,
                                 final String pattern, final Object ... arguments) {
-        super(rootCause);
-        this.pattern   = pattern;
-        this.arguments = (arguments == null) ? new Object[0] : arguments.clone();
+        this(rootCause, new DummyLocalizable(pattern), arguments);
     }
 
     /**
-     * Translate a string to a given locale.
-     * @param s string to translate
-     * @param locale locale into which to translate the string
-     * @return translated string or original string
-     * for unsupported locales or unknown strings
-     */
-    private static String translate(final String s, final Locale locale) {
-        try {
-            ResourceBundle bundle =
-                    ResourceBundle.getBundle("org.apache.commons.math.MessagesResources", locale);
-            if (bundle.getLocale().getLanguage().equals(locale.getLanguage())) {
-                // the value of the resource is the translated string
-                return bundle.getString(s);
-            }
-
-        } catch (MissingResourceException mre) {
-            // do nothing here
-        }
-
-        // the locale is not supported or the resource is unknown
-        // don't translate and fall back to using the string as is
-        return s;
-
+     * Constructs a new <code>MathRuntimeException</code> with specified
+     * formatted detail message and nested <code>Throwable</code> root cause.
+     * Message formatting is delegated to {@link java.text.MessageFormat}.
+     * @param rootCause the exception or error that caused this exception
+     * to be thrown.
+     * @param pattern format specifier
+     * @param arguments format arguments
+     * @since 2.2
+     */
+    public MathRuntimeException(final Throwable rootCause,
+                                final Localizable pattern, final Object ... arguments) {
+        super(rootCause);
+        this.pattern   = pattern;
+        this.arguments = (arguments == null) ? new Object[0] : arguments.clone();
     }
 
     /**
@@ -122,17 +129,29 @@ public class MathRuntimeException extend
      * @param pattern format specifier
      * @param arguments format arguments
      * @return a message string
+     * @since 2.2
      */
-    private static String buildMessage(final Locale locale, final String pattern,
+    private static String buildMessage(final Locale locale, final Localizable pattern,
                                        final Object ... arguments) {
-        return (pattern == null) ? "" : new MessageFormat(translate(pattern, locale), locale).format(arguments);
+        return new MessageFormat(pattern.getLocalizedString(locale), locale).format(arguments);
     }
 
     /** Gets the pattern used to build the message of this throwable.
+    *
+    * @return the pattern used to build the message of this throwable
+    * @deprecated as of 2.2 replaced by {@link #getLocalizablePattern()}
+    */
+    @Deprecated
+    public String getPattern() {
+        return pattern.getSourceString();
+    }
+
+    /** Gets the localizable pattern used to build the message of this throwable.
      *
-     * @return the pattern used to build the message of this throwable
+     * @return the localizable pattern used to build the message of this throwable
+     * @since 2.2
      */
-    public String getPattern() {
+    public Localizable getLocalizablePattern() {
         return pattern;
     }
 
@@ -151,7 +170,10 @@ public class MathRuntimeException extend
      * @return localized message
      */
     public String getMessage(final Locale locale) {
-        return buildMessage(locale, pattern, arguments);
+        if (pattern != null) {
+            return buildMessage(locale, pattern, arguments);
+        }
+        return "";
     }
 
     /** {@inheritDoc} */
@@ -198,10 +220,23 @@ public class MathRuntimeException extend
      */
     public static ArithmeticException createArithmeticException(final String pattern,
                                                                 final Object ... arguments) {
+        return createArithmeticException(new DummyLocalizable(pattern), arguments);
+    }
+
+    /**
+     * Constructs a new <code>ArithmeticException</code> with specified formatted detail message.
+     * Message formatting is delegated to {@link java.text.MessageFormat}.
+     * @param pattern format specifier
+     * @param arguments format arguments
+     * @return built exception
+     * @since 2.2
+     */
+    public static ArithmeticException createArithmeticException(final Localizable pattern,
+                                                                final Object ... arguments) {
         return new ArithmeticException() {
 
             /** Serializable version identifier. */
-            private static final long serialVersionUID = 7705628723242533939L;
+            private static final long serialVersionUID = 5305498554076846637L;
 
             /** {@inheritDoc} */
             @Override
@@ -227,10 +262,23 @@ public class MathRuntimeException extend
      */
     public static ArrayIndexOutOfBoundsException createArrayIndexOutOfBoundsException(final String pattern,
                                                                                       final Object ... arguments) {
+        return createArrayIndexOutOfBoundsException(new DummyLocalizable(pattern), arguments);
+    }
+
+    /**
+     * Constructs a new <code>ArrayIndexOutOfBoundsException</code> with specified formatted detail message.
+     * Message formatting is delegated to {@link java.text.MessageFormat}.
+     * @param pattern format specifier
+     * @param arguments format arguments
+     * @return built exception
+     * @since 2.2
+     */
+    public static ArrayIndexOutOfBoundsException createArrayIndexOutOfBoundsException(final Localizable pattern,
+                                                                                      final Object ... arguments) {
         return new ArrayIndexOutOfBoundsException() {
 
             /** Serializable version identifier. */
-            private static final long serialVersionUID = -3394748305449283486L;
+            private static final long serialVersionUID = 6718518191249632175L;
 
             /** {@inheritDoc} */
             @Override
@@ -256,10 +304,22 @@ public class MathRuntimeException extend
      */
     public static EOFException createEOFException(final String pattern,
                                                   final Object ... arguments) {
+        return createEOFException(new DummyLocalizable(pattern), arguments);
+    }
+
+    /**
+     * Constructs a new <code>EOFException</code> with specified formatted detail message.
+     * Message formatting is delegated to {@link java.text.MessageFormat}.
+     * @param pattern format specifier
+     * @param arguments format arguments
+     * @return built exception
+     */
+    public static EOFException createEOFException(final Localizable pattern,
+                                                  final Object ... arguments) {
         return new EOFException() {
 
             /** Serializable version identifier. */
-            private static final long serialVersionUID = 279461544586092584L;
+            private static final long serialVersionUID = 6067985859347601503L;
 
             /** {@inheritDoc} */
             @Override
@@ -302,10 +362,23 @@ public class MathRuntimeException extend
      */
     public static IllegalArgumentException createIllegalArgumentException(final String pattern,
                                                                           final Object ... arguments) {
+        return createIllegalArgumentException(new DummyLocalizable(pattern), arguments);
+    }
+
+    /**
+     * Constructs a new <code>IllegalArgumentException</code> with specified formatted detail message.
+     * Message formatting is delegated to {@link java.text.MessageFormat}.
+     * @param pattern format specifier
+     * @param arguments format arguments
+     * @return built exception
+     * @since 2.2
+     */
+    public static IllegalArgumentException createIllegalArgumentException(final Localizable pattern,
+                                                                          final Object ... arguments) {
         return new IllegalArgumentException() {
 
             /** Serializable version identifier. */
-            private static final long serialVersionUID = -6555453980658317913L;
+            private static final long serialVersionUID = -4284649691002411505L;
 
             /** {@inheritDoc} */
             @Override
@@ -344,10 +417,23 @@ public class MathRuntimeException extend
      */
     public static IllegalStateException createIllegalStateException(final String pattern,
                                                                     final Object ... arguments) {
+        return createIllegalStateException(new DummyLocalizable(pattern), arguments);
+    }
+
+    /**
+     * Constructs a new <code>IllegalStateException</code> with specified formatted detail message.
+     * Message formatting is delegated to {@link java.text.MessageFormat}.
+     * @param pattern format specifier
+     * @param arguments format arguments
+     * @return built exception
+     * @since 2.2
+     */
+    public static IllegalStateException createIllegalStateException(final Localizable pattern,
+                                                                    final Object ... arguments) {
         return new IllegalStateException() {
 
             /** Serializable version identifier. */
-            private static final long serialVersionUID = -95247648156277208L;
+            private static final long serialVersionUID = 6880901520234515725L;
 
             /** {@inheritDoc} */
             @Override
@@ -373,10 +459,23 @@ public class MathRuntimeException extend
      */
     public static ConcurrentModificationException createConcurrentModificationException(final String pattern,
                                                                                         final Object ... arguments) {
+        return createConcurrentModificationException(new DummyLocalizable(pattern), arguments);
+    }
+
+    /**
+     * Constructs a new <code>ConcurrentModificationException</code> with specified formatted detail message.
+     * Message formatting is delegated to {@link java.text.MessageFormat}.
+     * @param pattern format specifier
+     * @param arguments format arguments
+     * @return built exception
+     * @since 2.2
+     */
+    public static ConcurrentModificationException createConcurrentModificationException(final Localizable pattern,
+                                                                                        final Object ... arguments) {
         return new ConcurrentModificationException() {
 
             /** Serializable version identifier. */
-            private static final long serialVersionUID = 6134247282754009421L;
+            private static final long serialVersionUID = -1878427236170442052L;
 
             /** {@inheritDoc} */
             @Override
@@ -402,10 +501,23 @@ public class MathRuntimeException extend
      */
     public static NoSuchElementException createNoSuchElementException(final String pattern,
                                                                       final Object ... arguments) {
+        return createNoSuchElementException(new DummyLocalizable(pattern), arguments);
+    }
+
+    /**
+     * Constructs a new <code>NoSuchElementException</code> with specified formatted detail message.
+     * Message formatting is delegated to {@link java.text.MessageFormat}.
+     * @param pattern format specifier
+     * @param arguments format arguments
+     * @return built exception
+     * @since 2.2
+     */
+    public static NoSuchElementException createNoSuchElementException(final Localizable pattern,
+                                                                      final Object ... arguments) {
         return new NoSuchElementException() {
 
             /** Serializable version identifier. */
-            private static final long serialVersionUID = 7304273322489425799L;
+            private static final long serialVersionUID = 1632410088350355086L;
 
             /** {@inheritDoc} */
             @Override
@@ -431,10 +543,23 @@ public class MathRuntimeException extend
      */
     public static NullPointerException createNullPointerException(final String pattern,
                                                                   final Object ... arguments) {
+        return createNullPointerException(new DummyLocalizable(pattern), arguments);
+    }
+
+    /**
+     * Constructs a new <code>NullPointerException</code> with specified formatted detail message.
+     * Message formatting is delegated to {@link java.text.MessageFormat}.
+     * @param pattern format specifier
+     * @param arguments format arguments
+     * @return built exception
+     * @since 2.2
+     */
+    public static NullPointerException createNullPointerException(final Localizable pattern,
+                                                                  final Object ... arguments) {
         return new NullPointerException() {
 
             /** Serializable version identifier. */
-            private static final long serialVersionUID = -3075660477939965216L;
+            private static final long serialVersionUID = 451965530686593945L;
 
             /** {@inheritDoc} */
             @Override
@@ -463,10 +588,26 @@ public class MathRuntimeException extend
     public static ParseException createParseException(final int offset,
                                                       final String pattern,
                                                       final Object ... arguments) {
+        return createParseException(offset, new DummyLocalizable(pattern), arguments);
+    }
+
+    /**
+     * Constructs a new <code>ParseException</code> with specified
+     * formatted detail message.
+     * Message formatting is delegated to {@link java.text.MessageFormat}.
+     * @param offset offset at which error occurred
+     * @param pattern format specifier
+     * @param arguments format arguments
+     * @return built exception
+     * @since 2.2
+     */
+    public static ParseException createParseException(final int offset,
+                                                      final Localizable pattern,
+                                                      final Object ... arguments) {
         return new ParseException(null, offset) {
 
             /** Serializable version identifier. */
-            private static final long serialVersionUID = -1103502177342465975L;
+            private static final long serialVersionUID = 8153587599409010120L;
 
             /** {@inheritDoc} */
             @Override
@@ -489,7 +630,6 @@ public class MathRuntimeException extend
      */
     public static RuntimeException createInternalError(final Throwable cause) {
 
-        final String pattern  = "internal error, please fill a bug report at {0}";
         final String argument = "https://issues.apache.org/jira/browse/MATH";
 
         return new RuntimeException() {
@@ -500,13 +640,13 @@ public class MathRuntimeException extend
             /** {@inheritDoc} */
             @Override
             public String getMessage() {
-                return buildMessage(Locale.US, pattern, argument);
+                return buildMessage(Locale.US, LocalizedFormats.INTERNAL_ERROR, argument);
             }
 
             /** {@inheritDoc} */
             @Override
             public String getLocalizedMessage() {
-                return buildMessage(Locale.getDefault(), pattern, argument);
+                return buildMessage(Locale.getDefault(), LocalizedFormats.INTERNAL_ERROR, argument);
             }
 
         };

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/MaxEvaluationsExceededException.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/MaxEvaluationsExceededException.java?rev=955423&r1=955422&r2=955423&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/MaxEvaluationsExceededException.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/MaxEvaluationsExceededException.java Wed Jun 16 23:03:38 2010
@@ -18,6 +18,9 @@
 package org.apache.commons.math;
 
 import org.apache.commons.math.ConvergenceException;
+import org.apache.commons.math.util.DummyLocalizable;
+import org.apache.commons.math.util.Localizable;
+import org.apache.commons.math.util.LocalizedFormats;
 
 /**
  * Error thrown when a numerical computation exceeds its allowed
@@ -35,12 +38,11 @@ public class MaxEvaluationsExceededExcep
     private final int maxEvaluations;
 
     /**
-     * Constructs an exception with specified formatted detail message.
-     * Message formatting is delegated to {@link java.text.MessageFormat}.
+     * Constructs an exception with a default detail message.
      * @param maxEvaluations maximal number of evaluations allowed
      */
     public MaxEvaluationsExceededException(final int maxEvaluations) {
-        super("Maximal number of evaluations ({0}) exceeded", maxEvaluations);
+        super(LocalizedFormats.MAX_EVALUATIONS_EXCEEDED, maxEvaluations);
         this.maxEvaluations = maxEvaluations;
     }
 
@@ -50,9 +52,24 @@ public class MaxEvaluationsExceededExcep
      * @param maxEvaluations the exceeded maximal number of evaluations
      * @param pattern format specifier
      * @param arguments format arguments
+     * @deprecated as of 2.2 replaced by {@link #MaxEvaluationsExceededException(int, Localizable, Object...)}
      */
+    @Deprecated
     public MaxEvaluationsExceededException(final int maxEvaluations,
                                           final String pattern, final Object ... arguments) {
+        this(maxEvaluations, new DummyLocalizable(pattern), arguments);
+    }
+
+    /**
+     * Constructs an exception with specified formatted detail message.
+     * Message formatting is delegated to {@link java.text.MessageFormat}.
+     * @param maxEvaluations the exceeded maximal number of evaluations
+     * @param pattern format specifier
+     * @param arguments format arguments
+     * @since 2.2
+     */
+    public MaxEvaluationsExceededException(final int maxEvaluations,
+                                           final Localizable pattern, final Object ... arguments) {
         super(pattern, arguments);
         this.maxEvaluations = maxEvaluations;
     }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/MaxIterationsExceededException.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/MaxIterationsExceededException.java?rev=955423&r1=955422&r2=955423&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/MaxIterationsExceededException.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/MaxIterationsExceededException.java Wed Jun 16 23:03:38 2010
@@ -18,6 +18,9 @@
 package org.apache.commons.math;
 
 import org.apache.commons.math.ConvergenceException;
+import org.apache.commons.math.util.DummyLocalizable;
+import org.apache.commons.math.util.Localizable;
+import org.apache.commons.math.util.LocalizedFormats;
 
 /**
  * Error thrown when a numerical computation exceeds its allowed
@@ -35,12 +38,11 @@ public class MaxIterationsExceededExcept
     private final int maxIterations;
 
     /**
-     * Constructs an exception with specified formatted detail message.
-     * Message formatting is delegated to {@link java.text.MessageFormat}.
+     * Constructs an exception with a default detail message.
      * @param maxIterations maximal number of iterations allowed
      */
     public MaxIterationsExceededException(final int maxIterations) {
-        super("Maximal number of iterations ({0}) exceeded", maxIterations);
+        super(LocalizedFormats.MAX_ITERATIONS_EXCEEDED, maxIterations);
         this.maxIterations = maxIterations;
     }
 
@@ -50,9 +52,24 @@ public class MaxIterationsExceededExcept
      * @param maxIterations the exceeded maximal number of iterations
      * @param pattern format specifier
      * @param arguments format arguments
+     * @deprecated as of 2.2 replaced by {@link #MaxIterationsExceededException(int, Localizable, Object...)}
      */
+    @Deprecated
     public MaxIterationsExceededException(final int maxIterations,
                                           final String pattern, final Object ... arguments) {
+        this(maxIterations, new DummyLocalizable(pattern), arguments);
+    }
+
+    /**
+     * Constructs an exception with specified formatted detail message.
+     * Message formatting is delegated to {@link java.text.MessageFormat}.
+     * @param maxIterations the exceeded maximal number of iterations
+     * @param pattern format specifier
+     * @param arguments format arguments
+     * @since 2.2
+     */
+    public MaxIterationsExceededException(final int maxIterations,
+                                           final Localizable pattern, final Object ... arguments) {
         super(pattern, arguments);
         this.maxIterations = maxIterations;
     }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/RombergIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/RombergIntegrator.java?rev=955423&r1=955422&r2=955423&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/RombergIntegrator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/RombergIntegrator.java Wed Jun 16 23:03:38 2010
@@ -20,6 +20,7 @@ import org.apache.commons.math.FunctionE
 import org.apache.commons.math.MathRuntimeException;
 import org.apache.commons.math.MaxIterationsExceededException;
 import org.apache.commons.math.analysis.UnivariateRealFunction;
+import org.apache.commons.math.util.LocalizedFormats;
 
 /**
  * Implements the <a href="http://mathworld.wolfram.com/RombergIntegration.html">
@@ -113,7 +114,7 @@ public class RombergIntegrator extends U
         // at most 32 bisection refinements due to higher order divider
         if (maximalIterationCount > 32) {
             throw MathRuntimeException.createIllegalArgumentException(
-                    "invalid iteration limits: min={0}, max={1}",
+                    LocalizedFormats.INVALID_ITERATIONS_LIMITS,
                     0, 32);
         }
     }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/SimpsonIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/SimpsonIntegrator.java?rev=955423&r1=955422&r2=955423&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/SimpsonIntegrator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/SimpsonIntegrator.java Wed Jun 16 23:03:38 2010
@@ -20,6 +20,7 @@ import org.apache.commons.math.FunctionE
 import org.apache.commons.math.MathRuntimeException;
 import org.apache.commons.math.MaxIterationsExceededException;
 import org.apache.commons.math.analysis.UnivariateRealFunction;
+import org.apache.commons.math.util.LocalizedFormats;
 
 /**
  * Implements the <a href="http://mathworld.wolfram.com/SimpsonsRule.html">
@@ -104,7 +105,7 @@ public class SimpsonIntegrator extends U
         // at most 64 bisection refinements
         if (maximalIterationCount > 64) {
             throw MathRuntimeException.createIllegalArgumentException(
-                    "invalid iteration limits: min={0}, max={1}",
+                    LocalizedFormats.INVALID_ITERATIONS_LIMITS,
                     0, 64);
         }
     }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/TrapezoidIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/TrapezoidIntegrator.java?rev=955423&r1=955422&r2=955423&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/TrapezoidIntegrator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/TrapezoidIntegrator.java Wed Jun 16 23:03:38 2010
@@ -20,6 +20,7 @@ import org.apache.commons.math.FunctionE
 import org.apache.commons.math.MathRuntimeException;
 import org.apache.commons.math.MaxIterationsExceededException;
 import org.apache.commons.math.analysis.UnivariateRealFunction;
+import org.apache.commons.math.util.LocalizedFormats;
 
 /**
  * Implements the <a href="http://mathworld.wolfram.com/TrapezoidalRule.html">
@@ -135,7 +136,7 @@ public class TrapezoidIntegrator extends
         // at most 64 bisection refinements
         if (maximalIterationCount > 64) {
             throw MathRuntimeException.createIllegalArgumentException(
-                    "invalid iteration limits: min={0}, max={1}",
+                    LocalizedFormats.INVALID_ITERATIONS_LIMITS,
                     0, 64);
         }
     }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/UnivariateRealIntegratorImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/UnivariateRealIntegratorImpl.java?rev=955423&r1=955422&r2=955423&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/UnivariateRealIntegratorImpl.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/UnivariateRealIntegratorImpl.java Wed Jun 16 23:03:38 2010
@@ -19,6 +19,7 @@ package org.apache.commons.math.analysis
 import org.apache.commons.math.ConvergingAlgorithmImpl;
 import org.apache.commons.math.MathRuntimeException;
 import org.apache.commons.math.analysis.UnivariateRealFunction;
+import org.apache.commons.math.util.LocalizedFormats;
 
 /**
  * Provide a default implementation for several generic functions.
@@ -66,7 +67,7 @@ public abstract class UnivariateRealInte
         throws IllegalArgumentException {
         super(defaultMaximalIterationCount, 1.0e-15);
         if (f == null) {
-            throw MathRuntimeException.createIllegalArgumentException("function is null");
+            throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.NULL_FUNCTION);
         }
 
         this.f = f;
@@ -108,7 +109,7 @@ public abstract class UnivariateRealInte
         if (resultComputed) {
             return result;
         } else {
-            throw MathRuntimeException.createIllegalStateException("no result available");
+            throw MathRuntimeException.createIllegalStateException(LocalizedFormats.NO_RESULT_AVAILABLE);
         }
     }
 
@@ -171,7 +172,7 @@ public abstract class UnivariateRealInte
     protected void verifyIterationCount() throws IllegalArgumentException {
         if ((minimalIterationCount <= 0) || (maximalIterationCount <= minimalIterationCount)) {
             throw MathRuntimeException.createIllegalArgumentException(
-                    "invalid iteration limits: min={0}, max={1}",
+                    LocalizedFormats.INVALID_ITERATIONS_LIMITS,
                     minimalIterationCount, maximalIterationCount);
         }
     }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/BicubicSplineInterpolatingFunction.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/BicubicSplineInterpolatingFunction.java?rev=955423&r1=955422&r2=955423&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/BicubicSplineInterpolatingFunction.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/BicubicSplineInterpolatingFunction.java Wed Jun 16 23:03:38 2010
@@ -16,6 +16,7 @@
  */
 package org.apache.commons.math.analysis.interpolation;
 
+import org.apache.commons.math.util.LocalizedFormats;
 import org.apache.commons.math.util.MathUtils;
 import org.apache.commons.math.MathRuntimeException;
 import org.apache.commons.math.FunctionEvaluationException;
@@ -98,7 +99,7 @@ public class BicubicSplineInterpolatingF
         final int yLen = y.length;
 
         if (xLen == 0 || yLen == 0 || f.length == 0 || f[0].length == 0) {
-            throw MathRuntimeException.createIllegalArgumentException("no data");
+            throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.NO_DATA);
         }
         if (xLen != f.length) {
             throw new DimensionMismatchException(xLen, f.length);
@@ -157,13 +158,15 @@ public class BicubicSplineInterpolatingF
     public double value(double x, double y) {
         final int i = searchIndex(x, xval);
         if (i == -1) {
-            throw MathRuntimeException.createIllegalArgumentException("{0} out of [{1}, {2}] range",
-                                                                      x, xval[0], xval[xval.length - 1]);
+            throw MathRuntimeException.createIllegalArgumentException(
+                  LocalizedFormats.OUT_OF_RANGE_SIMPLE,
+                  x, xval[0], xval[xval.length - 1]);
         }
         final int j = searchIndex(y, yval);
         if (j == -1) {
-            throw MathRuntimeException.createIllegalArgumentException("{0} out of [{1}, {2}] range",
-                                                                      y, yval[0], yval[yval.length - 1]);
+            throw MathRuntimeException.createIllegalArgumentException(
+                  LocalizedFormats.OUT_OF_RANGE_SIMPLE,
+                  y, yval[0], yval[yval.length - 1]);
         }
 
         final double xN = (x - xval[i]) / (xval[i + 1] - xval[i]);
@@ -230,12 +233,12 @@ public class BicubicSplineInterpolatingF
 
         final int i = searchIndex(x, xval);
         if (i == -1) {
-            throw MathRuntimeException.createIllegalArgumentException("{0} out of [{1}, {2}] range",
+            throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.OUT_OF_RANGE_SIMPLE,
                                                                       x, xval[0], xval[xval.length - 1]);
         }
         final int j = searchIndex(y, yval);
         if (j == -1) {
-            throw MathRuntimeException.createIllegalArgumentException("{0} out of [{1}, {2}] range",
+            throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.OUT_OF_RANGE_SIMPLE,
                                                                       y, yval[0], yval[yval.length - 1]);
         }
 
@@ -373,11 +376,11 @@ class BicubicSplineFunction
      */
     public double value(double x, double y) {
         if (x < 0 || x > 1) {
-            throw MathRuntimeException.createIllegalArgumentException("{0} out of [{1}, {2}] range",
+            throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.OUT_OF_RANGE_SIMPLE,
                                                                       x, 0, 1);
         }
         if (y < 0 || y > 1) {
-            throw MathRuntimeException.createIllegalArgumentException("{0} out of [{1}, {2}] range",
+            throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.OUT_OF_RANGE_SIMPLE,
                                                                       y, 0, 1);
         }
 

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/BicubicSplineInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/BicubicSplineInterpolator.java?rev=955423&r1=955422&r2=955423&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/BicubicSplineInterpolator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/BicubicSplineInterpolator.java Wed Jun 16 23:03:38 2010
@@ -19,6 +19,7 @@ package org.apache.commons.math.analysis
 import org.apache.commons.math.DimensionMismatchException;
 import org.apache.commons.math.MathRuntimeException;
 import org.apache.commons.math.MathException;
+import org.apache.commons.math.util.LocalizedFormats;
 import org.apache.commons.math.util.MathUtils;
 import org.apache.commons.math.analysis.UnivariateRealFunction;
 import org.apache.commons.math.analysis.polynomials.PolynomialSplineFunction;
@@ -39,7 +40,7 @@ public class BicubicSplineInterpolator
                                                           final double[][] fval)
         throws MathException, IllegalArgumentException {
         if (xval.length == 0 || yval.length == 0 || fval.length == 0) {
-            throw MathRuntimeException.createIllegalArgumentException("no data");
+            throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.NO_DATA);
         }
         if (xval.length != fval.length) {
             throw new DimensionMismatchException(xval.length, fval.length);

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/LoessInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/LoessInterpolator.java?rev=955423&r1=955422&r2=955423&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/LoessInterpolator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/LoessInterpolator.java Wed Jun 16 23:03:38 2010
@@ -21,6 +21,8 @@ import java.util.Arrays;
 
 import org.apache.commons.math.MathException;
 import org.apache.commons.math.analysis.polynomials.PolynomialSplineFunction;
+import org.apache.commons.math.util.Localizable;
+import org.apache.commons.math.util.LocalizedFormats;
 
 /**
  * Implements the <a href="http://en.wikipedia.org/wiki/Local_regression">
@@ -145,14 +147,12 @@ public class LoessInterpolator
      */
     public LoessInterpolator(double bandwidth, int robustnessIters, double accuracy) throws MathException {
         if (bandwidth < 0 || bandwidth > 1) {
-            throw new MathException("bandwidth must be in the interval [0,1], but got {0}",
+            throw new MathException(LocalizedFormats.BANDWIDTH_OUT_OF_INTERVAL,
                                     bandwidth);
         }
         this.bandwidth = bandwidth;
         if (robustnessIters < 0) {
-            throw new MathException("the number of robustness iterations must " +
-                                    "be non-negative, but got {0}",
-                                    robustnessIters);
+            throw new MathException(LocalizedFormats.NEGATIVE_ROBUSTNESS_ITERATIONS, robustnessIters);
         }
         this.robustnessIters = robustnessIters;
         this.accuracy = accuracy;
@@ -198,22 +198,19 @@ public class LoessInterpolator
     public final double[] smooth(final double[] xval, final double[] yval, final double[] weights)
             throws MathException {
         if (xval.length != yval.length) {
-            throw new MathException(
-                    "Loess expects the abscissa and ordinate arrays " +
-                    "to be of the same size, " +
-                    "but got {0} abscissae and {1} ordinatae",
-                    xval.length, yval.length);
+            throw new MathException(LocalizedFormats.MISMATCHED_LOESS_ABSCISSA_ORDINATE_ARRAYS,
+                                    xval.length, yval.length);
         }
 
         final int n = xval.length;
 
         if (n == 0) {
-            throw new MathException("Loess expects at least 1 point");
+            throw new MathException(LocalizedFormats.LOESS_EXPECTS_AT_LEAST_ONE_POINT);
         }
 
-        checkAllFiniteReal(xval, "all abscissae must be finite real numbers, but {0}-th is {1}");
-        checkAllFiniteReal(yval, "all ordinatae must be finite real numbers, but {0}-th is {1}");
-        checkAllFiniteReal(weights, "all weights must be finite real numbers, but {0}-th is {1}");
+        checkAllFiniteReal(xval, LocalizedFormats.NON_REAL_FINITE_ABSCISSA);
+        checkAllFiniteReal(yval, LocalizedFormats.NON_REAL_FINITE_ORDINATE);
+        checkAllFiniteReal(weights, LocalizedFormats.NON_REAL_FINITE_WEIGHT);
 
         checkStrictlyIncreasing(xval);
 
@@ -228,12 +225,8 @@ public class LoessInterpolator
         int bandwidthInPoints = (int) (bandwidth * n);
 
         if (bandwidthInPoints < 2) {
-            throw new MathException(
-                    "the bandwidth must be large enough to " +
-                    "accomodate at least 2 points. There are {0} " +
-                    " data points, and bandwidth must be at least {1} " +
-                    " but it is only {2}",
-                    n, 2.0 / n, bandwidth);
+            throw new MathException(LocalizedFormats.TOO_SMALL_BANDWIDTH,
+                                    n, 2.0 / n, bandwidth);
         }
 
         final double[] res = new double[n];
@@ -365,11 +358,8 @@ public class LoessInterpolator
     public final double[] smooth(final double[] xval, final double[] yval)
             throws MathException {
         if (xval.length != yval.length) {
-            throw new MathException(
-                    "Loess expects the abscissa and ordinate arrays " +
-                    "to be of the same size, " +
-                    "but got {0} abscissae and {1} ordinatae",
-                    xval.length, yval.length);
+            throw new MathException(LocalizedFormats.MISMATCHED_LOESS_ABSCISSA_ORDINATE_ARRAYS,
+                                    xval.length, yval.length);
         }
 
         final double[] unitWeights = new double[xval.length];
@@ -442,7 +432,7 @@ public class LoessInterpolator
      * @param pattern pattern of the error message
      * @throws MathException if one of the values is not a finite real number
      */
-    private static void checkAllFiniteReal(final double[] values, final String pattern)
+    private static void checkAllFiniteReal(final double[] values, final Localizable pattern)
         throws MathException {
         for (int i = 0; i < values.length; i++) {
             final double x = values[i];
@@ -464,11 +454,8 @@ public class LoessInterpolator
         throws MathException {
         for (int i = 0; i < xval.length; ++i) {
             if (i >= 1 && xval[i - 1] >= xval[i]) {
-                throw new MathException(
-                        "the abscissae array must be sorted in a strictly " +
-                        "increasing order, but the {0}-th element is {1} " +
-                        "whereas {2}-th is {3}",
-                        i - 1, xval[i - 1], i, xval[i]);
+                throw new MathException(LocalizedFormats.OUT_OF_ORDER_ABSCISSA_ARRAY,
+                                        i - 1, xval[i - 1], i, xval[i]);
             }
         }
     }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/MicrosphereInterpolatingFunction.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/MicrosphereInterpolatingFunction.java?rev=955423&r1=955422&r2=955423&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/MicrosphereInterpolatingFunction.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/MicrosphereInterpolatingFunction.java Wed Jun 16 23:03:38 2010
@@ -27,6 +27,7 @@ import org.apache.commons.math.analysis.
 import org.apache.commons.math.linear.ArrayRealVector;
 import org.apache.commons.math.linear.RealVector;
 import org.apache.commons.math.random.UnitSphereRandomVectorGenerator;
+import org.apache.commons.math.util.LocalizedFormats;
 
 /**
  * Interpolating function that implements the
@@ -150,7 +151,7 @@ public class MicrosphereInterpolatingFun
                                             UnitSphereRandomVectorGenerator rand)
         throws DimensionMismatchException, IllegalArgumentException {
         if (xval.length == 0 || xval[0] == null) {
-            throw MathRuntimeException.createIllegalArgumentException("no data");
+            throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.NO_DATA);
         }
 
         if (xval.length != yval.length) {

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/MicrosphereInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/MicrosphereInterpolator.java?rev=955423&r1=955422&r2=955423&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/MicrosphereInterpolator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/MicrosphereInterpolator.java Wed Jun 16 23:03:38 2010
@@ -20,6 +20,7 @@ import org.apache.commons.math.MathExcep
 import org.apache.commons.math.MathRuntimeException;
 import org.apache.commons.math.analysis.MultivariateRealFunction;
 import org.apache.commons.math.random.UnitSphereRandomVectorGenerator;
+import org.apache.commons.math.util.LocalizedFormats;
 
 /**
  * Interpolator that implements the algorithm described in
@@ -100,7 +101,7 @@ public class MicrosphereInterpolator
     public void setBrightnessExponent(final int brightnessExponent) {
         if (brightnessExponent < 0) {
             throw MathRuntimeException.createIllegalArgumentException(
-                "brightness exponent should be positive or null, but got {0}",
+                LocalizedFormats.NEGATIVE_BRIGHTNESS_EXPONENT,
                 brightnessExponent);
         }
         this.brightnessExponent = brightnessExponent;
@@ -114,7 +115,7 @@ public class MicrosphereInterpolator
     public void setMicropshereElements(final int elements) {
         if (microsphereElements < 0) {
             throw MathRuntimeException.createIllegalArgumentException(
-                "number of microsphere elements must be positive, but got {0}",
+                LocalizedFormats.NON_POSITIVE_MICROSPHERE_ELEMENTS,
                 microsphereElements);
         }
         this.microsphereElements = elements;

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/SmoothingBicubicSplineInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/SmoothingBicubicSplineInterpolator.java?rev=955423&r1=955422&r2=955423&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/SmoothingBicubicSplineInterpolator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/SmoothingBicubicSplineInterpolator.java Wed Jun 16 23:03:38 2010
@@ -19,6 +19,7 @@ package org.apache.commons.math.analysis
 import org.apache.commons.math.DimensionMismatchException;
 import org.apache.commons.math.MathRuntimeException;
 import org.apache.commons.math.MathException;
+import org.apache.commons.math.util.LocalizedFormats;
 import org.apache.commons.math.util.MathUtils;
 import org.apache.commons.math.analysis.UnivariateRealFunction;
 import org.apache.commons.math.analysis.polynomials.PolynomialSplineFunction;
@@ -48,7 +49,7 @@ public class SmoothingBicubicSplineInter
                                                           final double[][] zval)
         throws MathException, IllegalArgumentException {
         if (xval.length == 0 || yval.length == 0 || zval.length == 0) {
-            throw MathRuntimeException.createIllegalArgumentException("no data");
+            throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.NO_DATA);
         }
         if (xval.length != zval.length) {
             throw new DimensionMismatchException(xval.length, zval.length);

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/SmoothingPolynomialBicubicSplineInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/SmoothingPolynomialBicubicSplineInterpolator.java?rev=955423&r1=955422&r2=955423&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/SmoothingPolynomialBicubicSplineInterpolator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/SmoothingPolynomialBicubicSplineInterpolator.java Wed Jun 16 23:03:38 2010
@@ -19,6 +19,7 @@ package org.apache.commons.math.analysis
 import org.apache.commons.math.DimensionMismatchException;
 import org.apache.commons.math.MathRuntimeException;
 import org.apache.commons.math.MathException;
+import org.apache.commons.math.util.LocalizedFormats;
 import org.apache.commons.math.util.MathUtils;
 import org.apache.commons.math.optimization.general.GaussNewtonOptimizer;
 import org.apache.commons.math.optimization.fitting.PolynomialFitter;
@@ -71,7 +72,7 @@ public class SmoothingPolynomialBicubicS
                                                           final double[][] fval)
         throws MathException, IllegalArgumentException {
         if (xval.length == 0 || yval.length == 0 || fval.length == 0) {
-            throw MathRuntimeException.createIllegalArgumentException("no data");
+            throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.NO_DATA);
         }
         if (xval.length != fval.length) {
             throw new DimensionMismatchException(xval.length, fval.length);



Mime
View raw message