Replaced obsolete exceptions.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1178806 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c733f8c422
commit
2dbc66e4fd
|
@ -41,8 +41,9 @@ public class ZeroException extends MathIllegalNumberException {
|
|||
* 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 implements MutationPolicy {
|
|||
/**
|
||||
* {@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());
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 implements Serializable, EmpiricalDistrib
|
|||
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 implements Serializable, EmpiricalDistrib
|
|||
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 implements Serializable, EmpiricalDistrib
|
|||
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 implements Serializable, EmpiricalDistrib
|
|||
* 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 implements Serializable, EmpiricalDistrib
|
|||
}
|
||||
}
|
||||
}
|
||||
throw new MathRuntimeException(LocalizedFormats.NO_BIN_SELECTED);
|
||||
throw new MathIllegalStateException(LocalizedFormats.NO_BIN_SELECTED);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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,7 +385,7 @@ public class ValueServer {
|
|||
closeReplayFile();
|
||||
resetReplayFile();
|
||||
if ((str = filePointer.readLine()) == null) {
|
||||
throw MathRuntimeException.createEOFException(LocalizedFormats.URL_CONTAINS_NO_DATA,
|
||||
throw new MathIllegalStateException(LocalizedFormats.URL_CONTAINS_NO_DATA,
|
||||
valuesFileURL);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue