commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r1061498 - in /commons/proper/math/trunk/src/main/java/org/apache/commons/math: exception/MathIllegalStateException.java exception/MathInternalError.java random/RandomDataImpl.java stat/ranking/NaturalRanking.java
Date Thu, 20 Jan 2011 20:32:54 GMT
Author: luc
Date: Thu Jan 20 20:32:54 2011
New Revision: 1061498

URL: http://svn.apache.org/viewvc?rev=1061498&view=rev
Log:
added MathInternalError

Added:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathInternalError.java
  (with props)
Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathIllegalStateException.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/stat/ranking/NaturalRanking.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathIllegalStateException.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathIllegalStateException.java?rev=1061498&r1=1061497&r2=1061498&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathIllegalStateException.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathIllegalStateException.java
Thu Jan 20 20:32:54 2011
@@ -31,6 +31,7 @@ public class MathIllegalStateException e
     private static final long serialVersionUID = -6024911025449780478L;
 
     /**
+     * Simple constructor.
      * @param specific Message pattern providing the specific context of
      * the error.
      * @param general Message pattern explaining the cause of the error.
@@ -39,16 +40,46 @@ public class MathIllegalStateException e
     public MathIllegalStateException(Localizable specific,
                                      Localizable general,
                                      Object ... args) {
-        super(null, specific, general, args);
+        super(null, 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, null, specific, general, args);
+    }
+
+    /**
+     * Simple constructor.
      * @param specific Message pattern explaining the cause of the error.
      * @param args Arguments.
      */
     public MathIllegalStateException(Localizable specific,
                                      Object ... args) {
-        this(specific, LocalizedFormats.ILLEGAL_STATE, args);
+        super(null, specific, LocalizedFormats.ILLEGAL_STATE, args);
     }
+
+    /**
+     * Simple constructor.
+     * @param cause root cause
+     * @param specific Message pattern explaining the cause of the error.
+     * @param args Arguments.
+     */
+    public MathIllegalStateException(Throwable cause,
+                                     Localizable specific,
+                                     Object ... args) {
+        super(cause, specific, LocalizedFormats.ILLEGAL_STATE, args);
+    }
+
     /**
      * @param args Arguments.
      */

Added: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathInternalError.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathInternalError.java?rev=1061498&view=auto
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathInternalError.java
(added)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathInternalError.java
Thu Jan 20 20:32:54 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/trunk/src/main/java/org/apache/commons/math/exception/MathInternalError.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathInternalError.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/RandomDataImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/RandomDataImpl.java?rev=1061498&r1=1061497&r2=1061498&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/RandomDataImpl.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/RandomDataImpl.java
Thu Jan 20 20:32:54 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/trunk/src/main/java/org/apache/commons/math/stat/ranking/NaturalRanking.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/ranking/NaturalRanking.java?rev=1061498&r1=1061497&r2=1061498&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/ranking/NaturalRanking.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/ranking/NaturalRanking.java
Thu Jan 20 20:32:54 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();
         }
     }
 



Mime
View raw message