Add missing Javadoc comments.

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@137735 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary D. Gregory 2003-12-29 00:58:27 +00:00
parent 77f538e305
commit 09e2ea6cc8
2 changed files with 82 additions and 18 deletions

View File

@ -60,7 +60,7 @@
* *
* @author Stephen Colebourne * @author Stephen Colebourne
* @since 2.0 * @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 { public final class LongRange extends Range implements Serializable {
@ -264,9 +264,11 @@ public long getMaximumLong() {
} }
/** /**
* <p>Gets the maximum number in this range as a <code>int</code>.</p> * <p>Gets the maximum number in this range cast to an <code>int</code>.</p>
* *
* <p>This conversion can lose information for large values.</p> * <p>This conversion can lose information for large values.</p>
*
* @return the maximum number in this range cast to an <code>int</code>.
*/ */
public int getMaximumInteger() { public int getMaximumInteger() {
return (int) max; return (int) max;

View File

@ -61,11 +61,15 @@
* method and its system-wide <code>Random</code> object. * method and its system-wide <code>Random</code> object.
* *
* @author Henri Yandell * @author Henri Yandell
* @author Gary D. Gregory
* @since 2.0 * @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 { public class RandomUtils {
/**
* An instance of {@link JVMRandom}.
*/
public static final Random JVM_RANDOM = new JVMRandom(); public static final Random JVM_RANDOM = new JVMRandom();
// should be possible for JVM_RANDOM? // should be possible for JVM_RANDOM?
@ -82,25 +86,44 @@ public class RandomUtils {
public static int nextInt() { public static int nextInt() {
return nextInt(JVM_RANDOM); return nextInt(JVM_RANDOM);
} }
public static int nextInt(Random rnd) {
return rnd.nextInt(); /**
* <p>Returns the next pseudorandom, uniformly distributed int value
* from the given <code>random</code> sequence.</p>
*
* @param random the Random sequence generator.
* @return the random int
*/
public static int nextInt(Random random) {
return random.nextInt();
} }
/** /**
* <p>Returns a pseudorandom, uniformly distributed int value * <p>Returns a pseudorandom, uniformly distributed int value
* between <code>0</code> (inclusive) and the specified value * between <code>0</code> (inclusive) and the specified value
* (exclusive), from the Math.random() sequence.</p> * (exclusive), from the Math.random() sequence.</p>
* *
* @param n the specified exclusive max-value * @param n the specified exclusive max-value
*
* @return the random int * @return the random int
*/ */
public static int nextInt(int n) { public static int nextInt(int n) {
return nextInt(JVM_RANDOM, n); return nextInt(JVM_RANDOM, n);
} }
public static int nextInt(Random rnd, int n) {
/**
* <p>Returns a pseudorandom, uniformly distributed int value
* between <code>0</code> (inclusive) and the specified value
* (exclusive), from the given Random sequence.</p>
*
* @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' // check this cannot return 'n'
return rnd.nextInt(n); return random.nextInt(n);
} }
/** /**
* <p>Returns the next pseudorandom, uniformly distributed long value * <p>Returns the next pseudorandom, uniformly distributed long value
* from the Math.random() sequence.</p> * from the Math.random() sequence.</p>
@ -110,9 +133,18 @@ public static int nextInt(Random rnd, int n) {
public static long nextLong() { public static long nextLong() {
return nextLong(JVM_RANDOM); return nextLong(JVM_RANDOM);
} }
public static long nextLong(Random rnd) {
return rnd.nextLong(); /**
* <p>Returns the next pseudorandom, uniformly distributed long value
* from the given Random sequence.</p>
*
* @param random the Random sequence generator.
* @return the random long
*/
public static long nextLong(Random random) {
return random.nextLong();
} }
/** /**
* <p>Returns the next pseudorandom, uniformly distributed boolean value * <p>Returns the next pseudorandom, uniformly distributed boolean value
* from the Math.random() sequence.</p> * from the Math.random() sequence.</p>
@ -122,9 +154,18 @@ public static long nextLong(Random rnd) {
public static boolean nextBoolean() { public static boolean nextBoolean() {
return nextBoolean(JVM_RANDOM); return nextBoolean(JVM_RANDOM);
} }
public static boolean nextBoolean(Random rnd) {
return rnd.nextBoolean(); /**
* <p>Returns the next pseudorandom, uniformly distributed boolean value
* from the given random sequence.</p>
*
* @param random the Random sequence generator.
* @return the random boolean
*/
public static boolean nextBoolean(Random random) {
return random.nextBoolean();
} }
/** /**
* <p>Returns the next pseudorandom, uniformly distributed float value * <p>Returns the next pseudorandom, uniformly distributed float value
* between <code>0.0</code> and <code>1.0</code> from the Math.random() * between <code>0.0</code> and <code>1.0</code> from the Math.random()
@ -135,19 +176,40 @@ public static boolean nextBoolean(Random rnd) {
public static float nextFloat() { public static float nextFloat() {
return nextFloat(JVM_RANDOM); return nextFloat(JVM_RANDOM);
} }
public static float nextFloat(Random rnd) {
return rnd.nextFloat();
}
/** /**
* <p>Synonymous to the Math.random() call.</p> * <p>Returns the next pseudorandom, uniformly distributed float value
* between <code>0.0</code> and <code>1.0</code> from the given Random
* sequence.</p>
*
* @param random the Random sequence generator.
* @return the random float
*/
public static float nextFloat(Random random) {
return random.nextFloat();
}
/**
* <p>Returns the next pseudorandom, uniformly distributed float value
* between <code>0.0</code> and <code>1.0</code> from the Math.random()
* sequence.</p>
* *
* @return the random double * @return the random double
*/ */
public static double nextDouble() { public static double nextDouble() {
return nextDouble(JVM_RANDOM); return nextDouble(JVM_RANDOM);
} }
public static double nextDouble(Random rnd) {
return rnd.nextDouble(); /**
* <p>Returns the next pseudorandom, uniformly distributed float value
* between <code>0.0</code> and <code>1.0</code> from the given Random
* sequence.</p>
*
* @param random the Random sequence generator.
* @return the random double
*/
public static double nextDouble(Random random) {
return random.nextDouble();
} }
} }