You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by lu...@apache.org on 2011/01/20 21:32:16 UTC
svn commit: r1061496 - in
/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math:
exception/MathIllegalStateException.java exception/MathInternalError.java
random/RandomDataImpl.java stat/ranking/NaturalRanking.java
Author: luc
Date: Thu Jan 20 20:32:16 2011
New Revision: 1061496
URL: http://svn.apache.org/viewvc?rev=1061496&view=rev
Log:
added MathInternalError
Added:
commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/exception/MathInternalError.java (with props)
Modified:
commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/exception/MathIllegalStateException.java
commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/random/RandomDataImpl.java
commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/stat/ranking/NaturalRanking.java
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/exception/MathIllegalStateException.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/exception/MathIllegalStateException.java?rev=1061496&r1=1061495&r2=1061496&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/exception/MathIllegalStateException.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/exception/MathIllegalStateException.java Thu Jan 20 20:32:16 2011
@@ -48,6 +48,7 @@ public class MathIllegalStateException e
private final Object[] arguments;
/**
+ * Simple constructor.
* @param specific Message pattern providing the specific context of
* the error.
* @param general Message pattern explaining the cause of the error.
@@ -56,17 +57,46 @@ public class MathIllegalStateException e
public MathIllegalStateException(Localizable specific,
Localizable general,
Object ... args) {
+ this(null, specific, general, args);
+ }
+
+ /**
+ * Simple constructor.
+ * @param cause root cause
+ * @param specific Message pattern providing the specific context of
+ * the error.
+ * @param general Message pattern explaining the cause of the error.
+ * @param args Arguments.
+ */
+ public MathIllegalStateException(Throwable cause,
+ Localizable specific,
+ Localizable general,
+ Object ... args) {
+ super(cause);
this.specific = specific;
this.general = general;
arguments = ArgUtils.flatten(args);
}
+
/**
* @param general Message pattern explaining the cause of the error.
* @param args Arguments.
*/
public MathIllegalStateException(Localizable general,
Object ... args) {
- this(null, general, args);
+ this(null, null, general, args);
+ }
+
+ /**
+ * Simple constructor.
+ * @param cause root cause
+ * @param general Message pattern explaining the cause of the error.
+ * @param args Arguments.
+ */
+ public MathIllegalStateException(Throwable cause,
+ Localizable general,
+ Object ... args) {
+ this(cause, null, general, args);
}
/** {@inheritDoc} */
Added: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/exception/MathInternalError.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/exception/MathInternalError.java?rev=1061496&view=auto
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/exception/MathInternalError.java (added)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/exception/MathInternalError.java Thu Jan 20 20:32:16 2011
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.math.exception;
+
+import org.apache.commons.math.exception.util.LocalizedFormats;
+
+/**
+ * Exception triggered when something that shouldn't happen does happen.
+ *
+ * @since 2.2
+ * @version $Revision$ $Date$
+ */
+public class MathInternalError extends MathIllegalStateException {
+
+ /** Serializable version Id. */
+ private static final long serialVersionUID = -6276776513966934846L;
+
+ /** URL for reporting problems. */
+ private static final String REPORT_URL = "https://issues.apache.org/jira/browse/MATH";
+
+ /**
+ * Simple constructor.
+ */
+ public MathInternalError() {
+ super(LocalizedFormats.INTERNAL_ERROR, REPORT_URL);
+ }
+
+ /**
+ * Simple constructor.
+ * @param cause root cause
+ */
+ public MathInternalError(final Throwable cause) {
+ super(LocalizedFormats.INTERNAL_ERROR, REPORT_URL);
+ }
+
+}
Propchange: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/exception/MathInternalError.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/exception/MathInternalError.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/random/RandomDataImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/random/RandomDataImpl.java?rev=1061496&r1=1061495&r2=1061496&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/random/RandomDataImpl.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/random/RandomDataImpl.java Thu Jan 20 20:32:16 2011
@@ -19,16 +19,12 @@ package org.apache.commons.math.random;
import java.io.Serializable;
import java.security.MessageDigest;
-import java.security.SecureRandom;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
+import java.security.SecureRandom;
import java.util.Collection;
import org.apache.commons.math.MathException;
-import org.apache.commons.math.MathRuntimeException;
-import org.apache.commons.math.exception.util.LocalizedFormats;
-import org.apache.commons.math.exception.NotStrictlyPositiveException;
-import org.apache.commons.math.exception.NumberIsTooLargeException;
import org.apache.commons.math.distribution.BetaDistributionImpl;
import org.apache.commons.math.distribution.BinomialDistributionImpl;
import org.apache.commons.math.distribution.CauchyDistributionImpl;
@@ -42,8 +38,12 @@ import org.apache.commons.math.distribut
import org.apache.commons.math.distribution.TDistributionImpl;
import org.apache.commons.math.distribution.WeibullDistributionImpl;
import org.apache.commons.math.distribution.ZipfDistributionImpl;
-import org.apache.commons.math.util.MathUtils;
+import org.apache.commons.math.exception.MathInternalError;
+import org.apache.commons.math.exception.NotStrictlyPositiveException;
+import org.apache.commons.math.exception.NumberIsTooLargeException;
+import org.apache.commons.math.exception.util.LocalizedFormats;
import org.apache.commons.math.util.FastMath;
+import org.apache.commons.math.util.MathUtils;
/**
* Implements the {@link RandomData} interface using a {@link RandomGenerator}
@@ -258,7 +258,7 @@ public class RandomDataImpl implements R
alg = MessageDigest.getInstance("SHA-1");
} catch (NoSuchAlgorithmException ex) {
// this should never happen
- throw MathRuntimeException.createInternalError(ex);
+ throw new MathInternalError(ex);
}
alg.reset();
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/stat/ranking/NaturalRanking.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/stat/ranking/NaturalRanking.java?rev=1061496&r1=1061495&r2=1061496&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/stat/ranking/NaturalRanking.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/stat/ranking/NaturalRanking.java Thu Jan 20 20:32:16 2011
@@ -22,7 +22,7 @@ import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
-import org.apache.commons.math.MathRuntimeException;
+import org.apache.commons.math.exception.MathInternalError;
import org.apache.commons.math.random.RandomData;
import org.apache.commons.math.random.RandomDataImpl;
import org.apache.commons.math.random.RandomGenerator;
@@ -211,7 +211,7 @@ public class NaturalRanking implements R
nanPositions = getNanPositions(ranks);
break;
default: // this should not happen unless NaNStrategy enum is changed
- throw MathRuntimeException.createInternalError(null);
+ throw new MathInternalError();
}
// Sort the IntDoublePairs
@@ -359,7 +359,7 @@ public class NaturalRanking implements R
}
break;
default: // this should not happen unless TiesStrategy enum is changed
- throw MathRuntimeException.createInternalError(null);
+ throw new MathInternalError();
}
}