commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r1178806 - in /commons/proper/math/trunk/src/main/java/org/apache/commons/math: exception/ZeroException.java genetics/RandomKeyMutation.java optimization/direct/BOBYQAOptimizer.java random/EmpiricalDistributionImpl.java random/ValueServer.java
Date Tue, 04 Oct 2011 14:14:03 GMT
Author: luc
Date: Tue Oct  4 14:14:02 2011
New Revision: 1178806

URL: http://svn.apache.org/viewvc?rev=1178806&view=rev
Log:
Replaced obsolete exceptions.

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/ZeroException.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/genetics/RandomKeyMutation.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/direct/BOBYQAOptimizer.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/ValueServer.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/ZeroException.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/ZeroException.java?rev=1178806&r1=1178805&r2=1178806&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/ZeroException.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/ZeroException.java
Tue Oct  4 14:14:02 2011
@@ -41,8 +41,9 @@ public class ZeroException extends MathI
      * Construct the exception with a specific context.
      *
      * @param specific Specific context pattern.
+     * @param arguments Arguments.
      */
-    public ZeroException(Localizable specific) {
-        super(specific, 0);
+    public ZeroException(Localizable specific, Object ... arguments) {
+        super(specific, 0, arguments);
     }
 }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/genetics/RandomKeyMutation.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/genetics/RandomKeyMutation.java?rev=1178806&r1=1178805&r2=1178806&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/genetics/RandomKeyMutation.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/genetics/RandomKeyMutation.java
Tue Oct  4 14:14:02 2011
@@ -19,7 +19,7 @@ package org.apache.commons.math.genetics
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.commons.math.MathRuntimeException;
+import org.apache.commons.math.exception.MathIllegalArgumentException;
 import org.apache.commons.math.exception.util.LocalizedFormats;
 
 /**
@@ -34,12 +34,12 @@ public class RandomKeyMutation implement
     /**
      * {@inheritDoc}
      *
-     * @throws IllegalArgumentException if <code>original</code> is not a
+     * @throws MathIllegalArgumentException if <code>original</code> is not a
      * {@link RandomKey} instance
      */
     public Chromosome mutate(Chromosome original) {
         if (!(original instanceof RandomKey<?>)) {
-            throw MathRuntimeException.createIllegalArgumentException(
+            throw new MathIllegalArgumentException(
                     LocalizedFormats.RANDOMKEY_MUTATION_WRONG_CLASS,
                     original.getClass().getSimpleName());
         }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/direct/BOBYQAOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/direct/BOBYQAOptimizer.java?rev=1178806&r1=1178805&r2=1178806&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/direct/BOBYQAOptimizer.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/direct/BOBYQAOptimizer.java
Tue Oct  4 14:14:02 2011
@@ -22,7 +22,6 @@ import java.util.Arrays;
 import org.apache.commons.math.analysis.MultivariateRealFunction;
 import org.apache.commons.math.exception.DimensionMismatchException;
 import org.apache.commons.math.exception.MathIllegalStateException;
-import org.apache.commons.math.exception.MathInternalError;
 import org.apache.commons.math.exception.NumberIsTooSmallException;
 import org.apache.commons.math.exception.OutOfRangeException;
 import org.apache.commons.math.exception.util.LocalizedFormats;

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/EmpiricalDistributionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/EmpiricalDistributionImpl.java?rev=1178806&r1=1178805&r2=1178806&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/EmpiricalDistributionImpl.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/EmpiricalDistributionImpl.java
Tue Oct  4 14:14:02 2011
@@ -27,8 +27,10 @@ import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.commons.math.MathRuntimeException;
+import org.apache.commons.math.exception.MathIllegalArgumentException;
+import org.apache.commons.math.exception.MathIllegalStateException;
 import org.apache.commons.math.exception.NullArgumentException;
+import org.apache.commons.math.exception.ZeroException;
 import org.apache.commons.math.exception.util.LocalizedFormats;
 import org.apache.commons.math.stat.descriptive.StatisticalSummary;
 import org.apache.commons.math.stat.descriptive.SummaryStatistics;
@@ -176,7 +178,7 @@ public class EmpiricalDistributionImpl i
             da.computeStats();
             fillBinStats(in);
         } catch (IOException e) {
-            throw new MathRuntimeException(e);
+            throw new MathIllegalStateException(e, LocalizedFormats.SIMPLE_MESSAGE, e.getLocalizedMessage());
         }
         loaded = true;
 
@@ -197,8 +199,7 @@ public class EmpiricalDistributionImpl i
             DataAdapter da = new StreamDataAdapter(in);
             da.computeStats();
             if (sampleStats.getN() == 0) {
-                throw MathRuntimeException.createEOFException(LocalizedFormats.URL_CONTAINS_NO_DATA,
-                                                              url);
+                throw new ZeroException(LocalizedFormats.URL_CONTAINS_NO_DATA, url);
             }
             in = new BufferedReader(new InputStreamReader(url.openStream()));
             fillBinStats(in);
@@ -279,7 +280,7 @@ public class EmpiricalDistributionImpl i
                 double[] inputArray = (double[]) in;
                 return new ArrayDataAdapter(inputArray);
             } else {
-                throw MathRuntimeException.createIllegalArgumentException(
+                throw new MathIllegalArgumentException(
                       LocalizedFormats.INPUT_DATA_FROM_UNSUPPORTED_DATASOURCE,
                       in.getClass().getName(),
                       BufferedReader.class.getName(), double[].class.getName());
@@ -427,12 +428,12 @@ public class EmpiricalDistributionImpl i
      * Generates a random value from this distribution.
      *
      * @return the random value.
-     * @throws IllegalStateException if the distribution has not been loaded
+     * @throws MathIllegalStateException if the distribution has not been loaded
      */
     public double getNextValue() throws IllegalStateException {
 
         if (!loaded) {
-            throw MathRuntimeException.createIllegalStateException(LocalizedFormats.DISTRIBUTION_NOT_LOADED);
+            throw new MathIllegalStateException(LocalizedFormats.DISTRIBUTION_NOT_LOADED);
         }
 
         // Start with a uniformly distributed random number in (0,1)
@@ -452,7 +453,7 @@ public class EmpiricalDistributionImpl i
                }
            }
         }
-        throw new MathRuntimeException(LocalizedFormats.NO_BIN_SELECTED);
+        throw new MathIllegalStateException(LocalizedFormats.NO_BIN_SELECTED);
     }
 
     /**

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/ValueServer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/ValueServer.java?rev=1178806&r1=1178805&r2=1178806&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/ValueServer.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/ValueServer.java
Tue Oct  4 14:14:02 2011
@@ -22,7 +22,7 @@ import java.io.InputStreamReader;
 import java.net.MalformedURLException;
 import java.net.URL;
 
-import org.apache.commons.math.MathRuntimeException;
+import org.apache.commons.math.exception.MathIllegalStateException;
 import org.apache.commons.math.exception.util.LocalizedFormats;
 
 /**
@@ -120,7 +120,7 @@ public class ValueServer {
             case EXPONENTIAL_MODE: return getNextExponential();
             case GAUSSIAN_MODE: return getNextGaussian();
             case CONSTANT_MODE: return mu;
-            default: throw MathRuntimeException.createIllegalStateException(
+            default: throw new MathIllegalStateException(
                     LocalizedFormats.UNKNOWN_MODE,
                     mode,
                     "DIGEST_MODE",   DIGEST_MODE,   "REPLAY_MODE",      REPLAY_MODE,
@@ -352,7 +352,7 @@ public class ValueServer {
     private double getNextDigest() {
         if ((empiricalDistribution == null) ||
             (empiricalDistribution.getBinStats().size() == 0)) {
-            throw MathRuntimeException.createIllegalStateException(LocalizedFormats.DIGEST_NOT_INITIALIZED);
+            throw new MathIllegalStateException(LocalizedFormats.DIGEST_NOT_INITIALIZED);
         }
         return empiricalDistribution.getNextValue();
     }
@@ -385,8 +385,8 @@ public class ValueServer {
             closeReplayFile();
             resetReplayFile();
             if ((str = filePointer.readLine()) == null) {
-                throw MathRuntimeException.createEOFException(LocalizedFormats.URL_CONTAINS_NO_DATA,
-                                                              valuesFileURL);
+                throw new MathIllegalStateException(LocalizedFormats.URL_CONTAINS_NO_DATA,
+                                                    valuesFileURL);
             }
         }
         return Double.valueOf(str).doubleValue();



Mime
View raw message