From 09e2ea6cc8f18438eeba5fdce312508348b01f4f Mon Sep 17 00:00:00 2001 From: "Gary D. Gregory" Date: Mon, 29 Dec 2003 00:58:27 +0000 Subject: [PATCH] Add missing Javadoc comments. git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@137735 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/commons/lang/math/LongRange.java | 6 +- .../apache/commons/lang/math/RandomUtils.java | 94 +++++++++++++++---- 2 files changed, 82 insertions(+), 18 deletions(-) diff --git a/src/java/org/apache/commons/lang/math/LongRange.java b/src/java/org/apache/commons/lang/math/LongRange.java index b07412c95..7ba03be52 100644 --- a/src/java/org/apache/commons/lang/math/LongRange.java +++ b/src/java/org/apache/commons/lang/math/LongRange.java @@ -60,7 +60,7 @@ * * @author Stephen Colebourne * @since 2.0 - * @version $Id: LongRange.java,v 1.5 2003/08/18 02:22:24 bayard Exp $ + * @version $Id: LongRange.java,v 1.6 2003/12/29 00:58:27 ggregory Exp $ */ public final class LongRange extends Range implements Serializable { @@ -264,9 +264,11 @@ public long getMaximumLong() { } /** - *

Gets the maximum number in this range as a int.

+ *

Gets the maximum number in this range cast to an int.

* *

This conversion can lose information for large values.

+ * + * @return the maximum number in this range cast to an int. */ public int getMaximumInteger() { return (int) max; diff --git a/src/java/org/apache/commons/lang/math/RandomUtils.java b/src/java/org/apache/commons/lang/math/RandomUtils.java index 084a3b483..d7a7fc307 100644 --- a/src/java/org/apache/commons/lang/math/RandomUtils.java +++ b/src/java/org/apache/commons/lang/math/RandomUtils.java @@ -61,11 +61,15 @@ * method and its system-wide Random object. * * @author Henri Yandell + * @author Gary D. Gregory * @since 2.0 - * @version $Id: RandomUtils.java,v 1.6 2003/08/18 02:22:24 bayard Exp $ + * @version $Id: RandomUtils.java,v 1.7 2003/12/29 00:58:27 ggregory Exp $ */ public class RandomUtils { + /** + * An instance of {@link JVMRandom}. + */ public static final Random JVM_RANDOM = new JVMRandom(); // should be possible for JVM_RANDOM? @@ -82,25 +86,44 @@ public class RandomUtils { public static int nextInt() { return nextInt(JVM_RANDOM); } - public static int nextInt(Random rnd) { - return rnd.nextInt(); + + /** + *

Returns the next pseudorandom, uniformly distributed int value + * from the given random sequence.

+ * + * @param random the Random sequence generator. + * @return the random int + */ + public static int nextInt(Random random) { + return random.nextInt(); } + /** *

Returns a pseudorandom, uniformly distributed int value * between 0 (inclusive) and the specified value * (exclusive), from the Math.random() sequence.

* * @param n the specified exclusive max-value - * * @return the random int */ public static int nextInt(int n) { return nextInt(JVM_RANDOM, n); } - public static int nextInt(Random rnd, int n) { + + /** + *

Returns a pseudorandom, uniformly distributed int value + * between 0 (inclusive) and the specified value + * (exclusive), from the given Random sequence.

+ * + * @param random the Random sequence generator. + * @param n the specified exclusive max-value + * @return the random int + */ + public static int nextInt(Random random, int n) { // check this cannot return 'n' - return rnd.nextInt(n); + return random.nextInt(n); } + /** *

Returns the next pseudorandom, uniformly distributed long value * from the Math.random() sequence.

@@ -110,9 +133,18 @@ public static int nextInt(Random rnd, int n) { public static long nextLong() { return nextLong(JVM_RANDOM); } - public static long nextLong(Random rnd) { - return rnd.nextLong(); + + /** + *

Returns the next pseudorandom, uniformly distributed long value + * from the given Random sequence.

+ * + * @param random the Random sequence generator. + * @return the random long + */ + public static long nextLong(Random random) { + return random.nextLong(); } + /** *

Returns the next pseudorandom, uniformly distributed boolean value * from the Math.random() sequence.

@@ -122,9 +154,18 @@ public static long nextLong(Random rnd) { public static boolean nextBoolean() { return nextBoolean(JVM_RANDOM); } - public static boolean nextBoolean(Random rnd) { - return rnd.nextBoolean(); + + /** + *

Returns the next pseudorandom, uniformly distributed boolean value + * from the given random sequence.

+ * + * @param random the Random sequence generator. + * @return the random boolean + */ + public static boolean nextBoolean(Random random) { + return random.nextBoolean(); } + /** *

Returns the next pseudorandom, uniformly distributed float value * between 0.0 and 1.0 from the Math.random() @@ -135,19 +176,40 @@ public static boolean nextBoolean(Random rnd) { public static float nextFloat() { return nextFloat(JVM_RANDOM); } - public static float nextFloat(Random rnd) { - return rnd.nextFloat(); - } + /** - *

Synonymous to the Math.random() call.

+ *

Returns the next pseudorandom, uniformly distributed float value + * between 0.0 and 1.0 from the given Random + * sequence.

+ * + * @param random the Random sequence generator. + * @return the random float + */ + public static float nextFloat(Random random) { + return random.nextFloat(); + } + + /** + *

Returns the next pseudorandom, uniformly distributed float value + * between 0.0 and 1.0 from the Math.random() + * sequence.

* * @return the random double */ public static double nextDouble() { return nextDouble(JVM_RANDOM); } - public static double nextDouble(Random rnd) { - return rnd.nextDouble(); + + /** + *

Returns the next pseudorandom, uniformly distributed float value + * between 0.0 and 1.0 from the given Random + * sequence.

+ * + * @param random the Random sequence generator. + * @return the random double + */ + public static double nextDouble(Random random) { + return random.nextDouble(); } }