commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From celes...@apache.org
Subject svn commit: r1231847 - in /commons/proper/math/trunk/src/main/java/org/apache/commons/math/random: RandomData.java RandomDataImpl.java
Date Mon, 16 Jan 2012 06:38:28 GMT
Author: celestin
Date: Mon Jan 16 06:38:27 2012
New Revision: 1231847

URL: http://svn.apache.org/viewvc?rev=1231847&view=rev
Log:
Removed unchecked exceptions from method signatures. See
  - Commons-Dev mailing list http://mail-archives.apache.org/mod_mbox/commons-dev/201201.mbox/%3C20120113105913.GM6537%40dusk.harfang.homelinux.org%3E
  - "Effective Java, second edition", item 62.

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/RandomData.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/RandomDataImpl.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/RandomData.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/RandomData.java?rev=1231847&r1=1231846&r2=1231847&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/RandomData.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/RandomData.java
Mon Jan 16 06:38:27 2012
@@ -18,9 +18,6 @@
 package org.apache.commons.math.random;
 import java.util.Collection;
 
-import org.apache.commons.math.exception.NotStrictlyPositiveException;
-import org.apache.commons.math.exception.NumberIsTooLargeException;
-
 /**
  * Random data generation utilities.
  * @version $Id$
@@ -36,9 +33,10 @@ public interface RandomData {
      *
      * @param len the length of the string to be generated
      * @return a random string of hex characters of length {@code len}
-     * @throws NotStrictlyPositiveException if {@code len <= 0}
+     * @throws org.apache.commons.math.exception.NotStrictlyPositiveException
+     * if {@code len <= 0}
      */
-    String nextHexString(int len) throws NotStrictlyPositiveException;
+    String nextHexString(int len);
 
     /**
      * Generates a uniformly distributed random integer between {@code lower}
@@ -53,9 +51,10 @@ public interface RandomData {
      * @param upper upper bound for generated integer
      * @return a random integer greater than or equal to {@code lower}
      * and less than or equal to {@code upper}
-     * @throws NumberIsTooLargeException if {@code lower >= upper}
+     * @throws org.apache.commons.math.exception.NumberIsTooLargeException
+     * if {@code lower >= upper}
      */
-    int nextInt(int lower, int upper) throws NumberIsTooLargeException;
+    int nextInt(int lower, int upper);
 
     /**
      * Generates a uniformly distributed random long integer between
@@ -70,9 +69,10 @@ public interface RandomData {
      * @param upper upper bound for generated long integer
      * @return a random long integer greater than or equal to {@code lower} and
      * less than or equal to {@code upper}
-     * @throws NumberIsTooLargeException if {@code lower >= upper}.
+     * @throws org.apache.commons.math.exception.NumberIsTooLargeException
+     * if {@code lower >= upper}.
      */
-    long nextLong(long lower, long upper) throws NumberIsTooLargeException;
+    long nextLong(long lower, long upper);
 
     /**
      * Generates a random string of hex characters from a secure random
@@ -84,9 +84,10 @@ public interface RandomData {
      *
      * @param len the length of the string to be generated
      * @return a random string of hex characters of length {@code len}
-     * @throws NotStrictlyPositiveException if {@code len <= 0}
+     * @throws org.apache.commons.math.exception.NotStrictlyPositiveException
+     * if {@code len <= 0}
      */
-    String nextSecureHexString(int len) throws NotStrictlyPositiveException;
+    String nextSecureHexString(int len);
 
     /**
      * Generates a uniformly distributed random integer between {@code lower}
@@ -104,9 +105,10 @@ public interface RandomData {
      * @param upper upper bound for generated integer
      * @return a random integer greater than or equal to {@code lower} and less
      * than or equal to {@code upper}.
-     * @throws NumberIsTooLargeException if {@code lower >= upper}.
+     * @throws org.apache.commons.math.exception.NumberIsTooLargeException
+     * if {@code lower >= upper}.
      */
-    int nextSecureInt(int lower, int upper) throws NumberIsTooLargeException;
+    int nextSecureInt(int lower, int upper);
 
     /**
      * Generates a uniformly distributed random long integer between
@@ -125,10 +127,10 @@ public interface RandomData {
      * @param upper upper bound for generated integer
      * @return a random long integer greater than or equal to {@code lower} and
      * less than or equal to {@code upper}.
-     * @throws NumberIsTooLargeException if {@code lower >= upper}.
+     * @throws org.apache.commons.math.exception.NumberIsTooLargeException
+     * if {@code lower >= upper}.
      */
-    long nextSecureLong(long lower, long upper)
-            throws NumberIsTooLargeException;
+    long nextSecureLong(long lower, long upper);
 
     /**
      * Generates a random value from the Poisson distribution with the given
@@ -140,9 +142,10 @@ public interface RandomData {
      *
      * @param mean the mean of the Poisson distribution
      * @return a random value following the specified Poisson distribution
-     * @throws NotStrictlyPositiveException if {@code mean <= 0}.
+     * @throws org.apache.commons.math.exception.NotStrictlyPositiveException
+     * if {@code mean <= 0}.
      */
-    long nextPoisson(double mean) throws NotStrictlyPositiveException;
+    long nextPoisson(double mean);
 
     /**
      * Generates a random value from the Normal (or Gaussian) distribution with
@@ -155,10 +158,10 @@ public interface RandomData {
      * @param mu the mean of the distribution
      * @param sigma the standard deviation of the distribution
      * @return a random value following the specified Gaussian distribution
-     * @throws NotStrictlyPositiveException if {@code sigma <= 0}.
+     * @throws org.apache.commons.math.exception.NotStrictlyPositiveException
+     * if {@code sigma <= 0}.
      */
-    double nextGaussian(double mu, double sigma)
-            throws NotStrictlyPositiveException;
+    double nextGaussian(double mu, double sigma);
 
     /**
      * Generates a random value from the exponential distribution
@@ -170,9 +173,10 @@ public interface RandomData {
      *
      * @param mean the mean of the distribution
      * @return a random value following the specified exponential distribution
-     * @throws NotStrictlyPositiveException if {@code mean <= 0}.
+     * @throws org.apache.commons.math.exception.NotStrictlyPositiveException
+     * if {@code mean <= 0}.
      */
-    double nextExponential(double mean) throws NotStrictlyPositiveException;
+    double nextExponential(double mean);
 
     /**
      * Generates a uniformly distributed random value from the open interval
@@ -188,10 +192,10 @@ public interface RandomData {
      * @param upper the exclusive upper bound of the support
      * @return a uniformly distributed random value between lower and upper
      * (exclusive)
-     * @throws NumberIsTooLargeException if {@code lower >= upper}
+     * @throws org.apache.commons.math.exception.NumberIsTooLargeException
+     * if {@code lower >= upper}
      */
-    double nextUniform(double lower, double upper)
-            throws NumberIsTooLargeException;
+    double nextUniform(double lower, double upper);
 
     /**
      * Generates a uniformly distributed random value from the interval
@@ -210,11 +214,12 @@ public interface RandomData {
      * @param lowerInclusive {@code true} if the lower bound is inclusive
      * @return uniformly distributed random value in the {@code (lower, upper)}
      * interval, if {@code lowerInclusive} is {@code false}, or in the
-     * {@code [lower, upper)} interval, if {@code lowerInclusive} is {@code true}
-     * @throws NumberIsTooLargeException if {@code lower >= upper}
+     * {@code [lower, upper)} interval, if {@code lowerInclusive} is
+     * {@code true}
+     * @throws org.apache.commons.math.exception.NumberIsTooLargeException
+     * if {@code lower >= upper}
      */
-    double nextUniform(double lower, double upper, boolean lowerInclusive)
-            throws NumberIsTooLargeException;
+    double nextUniform(double lower, double upper, boolean lowerInclusive);
 
     /**
      * Generates an integer array of length {@code k} whose entries are selected
@@ -228,11 +233,12 @@ public interface RandomData {
      * @param k the size of the permutation
      * @return a random {@code k}-permutation of {@code n}, as an array of
      * integers
-     * @throws NumberIsTooLargeException if {@code k > n}.
-     * @throws NotStrictlyPositiveException if {@code k <= 0}.
+     * @throws org.apache.commons.math.exception.NumberIsTooLargeException
+     * if {@code k > n}.
+     * @throws org.apache.commons.math.exception.NotStrictlyPositiveException
+     * if {@code k <= 0}.
      */
-    int[] nextPermutation(int n, int k)
-            throws NumberIsTooLargeException, NotStrictlyPositiveException;
+    int[] nextPermutation(int n, int k);
 
     /**
      * Returns an array of {@code k} objects selected randomly from the
@@ -248,9 +254,10 @@ public interface RandomData {
      * @param c the collection to be sampled
      * @param k the size of the sample
      * @return a random sample of {@code k} elements from {@code c}
-     * @throws NumberIsTooLargeException if {@code k > c.size()}.
-     * @throws NotStrictlyPositiveException if {@code k <= 0}.
+     * @throws org.apache.commons.math.exception.NumberIsTooLargeException
+     * if {@code k > c.size()}.
+     * @throws org.apache.commons.math.exception.NotStrictlyPositiveException
+     * if {@code k <= 0}.
      */
-    Object[] nextSample(Collection<?> c, int k)
-            throws NumberIsTooLargeException, NotStrictlyPositiveException;
+    Object[] nextSample(Collection<?> c, int k);
 }

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=1231847&r1=1231846&r2=1231847&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
Mon Jan 16 06:38:27 2012
@@ -197,7 +197,7 @@ public class RandomDataImpl implements R
      * @return the random string.
      * @throws NotStrictlyPositiveException if {@code len <= 0}.
      */
-    public String nextHexString(int len) throws NotStrictlyPositiveException {
+    public String nextHexString(int len) {
         if (len <= 0) {
             throw new NotStrictlyPositiveException(LocalizedFormats.LENGTH, len);
         }
@@ -233,7 +233,7 @@ public class RandomDataImpl implements R
     }
 
     /** {@inheritDoc} */
-    public int nextInt(int lower, int upper) throws NumberIsTooLargeException {
+    public int nextInt(int lower, int upper) {
         if (lower >= upper) {
             throw new NumberIsTooLargeException(LocalizedFormats.LOWER_BOUND_NOT_BELOW_UPPER_BOUND,
                                                 lower, upper, false);
@@ -270,7 +270,7 @@ public class RandomDataImpl implements R
      * </ol>
      * </p>
      */
-    public String nextSecureHexString(int len) throws NotStrictlyPositiveException {
+    public String nextSecureHexString(int len) {
         if (len <= 0) {
             throw new NotStrictlyPositiveException(LocalizedFormats.LENGTH, len);
         }
@@ -332,8 +332,7 @@ public class RandomDataImpl implements R
     }
 
     /** {@inheritDoc} */
-    public long nextSecureLong(long lower, long upper)
-        throws NumberIsTooLargeException {
+    public long nextSecureLong(long lower, long upper) {
 
         if (lower >= upper) {
             throw new NumberIsTooLargeException(LocalizedFormats.LOWER_BOUND_NOT_BELOW_UPPER_BOUND,
@@ -358,7 +357,7 @@ public class RandomDataImpl implements R
      * Devroye, Luc. (1981).<i>The Computer Generation of Poisson Random Variables</i>
      * <strong>Computing</strong> vol. 26 pp. 197-207.</li></ul></p>
      */
-    public long nextPoisson(double mean) throws NotStrictlyPositiveException {
+    public long nextPoisson(double mean) {
         if (mean <= 0) {
             throw new NotStrictlyPositiveException(LocalizedFormats.MEAN, mean);
         }
@@ -450,8 +449,7 @@ public class RandomDataImpl implements R
     }
 
     /** {@inheritDoc} */
-    public double nextGaussian(double mu, double sigma)
-        throws NotStrictlyPositiveException {
+    public double nextGaussian(double mu, double sigma) {
 
         if (sigma <= 0) {
             throw new NotStrictlyPositiveException(LocalizedFormats.STANDARD_DEVIATION, sigma);
@@ -470,8 +468,7 @@ public class RandomDataImpl implements R
      * Communications of the ACM, 15, 873-882.
      * </p>
      */
-    public double nextExponential(double mean)
-        throws NotStrictlyPositiveException {
+    public double nextExponential(double mean) {
 
         if (mean <= 0.0) {
             throw new NotStrictlyPositiveException(LocalizedFormats.MEAN, mean);
@@ -528,8 +525,7 @@ public class RandomDataImpl implements R
      * @throws MathIllegalArgumentException if one of the bounds is infinite or
      * {@code NaN} or either bound is infinite or NaN
      */
-    public double nextUniform(double lower, double upper)
-        throws NumberIsTooLargeException, MathIllegalArgumentException {
+    public double nextUniform(double lower, double upper) {
 
         return nextUniform(lower, upper, false);
     }
@@ -550,8 +546,7 @@ public class RandomDataImpl implements R
      * @since 3.0
      */
     public double nextUniform(double lower, double upper,
-        boolean lowerInclusive)
-        throws NumberIsTooLargeException, MathIllegalArgumentException {
+        boolean lowerInclusive) {
 
         if (lower >= upper) {
             throw new NumberIsTooLargeException(LocalizedFormats.LOWER_BOUND_NOT_BELOW_UPPER_BOUND,
@@ -969,8 +964,7 @@ public class RandomDataImpl implements R
      * here</a>
      * </p>
      */
-    public Object[] nextSample(Collection<?> c, int k)
-        throws NumberIsTooLargeException, NotStrictlyPositiveException {
+    public Object[] nextSample(Collection<?> c, int k) {
 
         int len = c.size();
         if (k > len) {



Mime
View raw message