ggregory    2003/12/28 16:58:27

  Modified:    lang/src/java/org/apache/commons/lang/math RandomUtils.java
                        LongRange.java
  Log:
  Add missing Javadoc comments.
  
  Revision  Changes    Path
  1.7       +77 -15    
jakarta-commons/lang/src/java/org/apache/commons/lang/math/RandomUtils.java
  
  Index: RandomUtils.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/math/RandomUtils.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- RandomUtils.java  18 Aug 2003 02:22:24 -0000      1.6
  +++ RandomUtils.java  29 Dec 2003 00:58:27 -0000      1.7
  @@ -61,11 +61,15 @@
    * method and its system-wide <code>Random</code> object.
    * 
    * @author Henri Yandell
  + * @author Gary D. Gregory
    * @since 2.0
    * @version $Id$
    */
   public class RandomUtils {
   
  +    /**
  +     * An instance of [EMAIL PROTECTED] JVMRandom}.
  +     */
       public static final Random JVM_RANDOM = new JVMRandom();
   
   // should be possible for JVM_RANDOM?
  @@ -82,25 +86,44 @@
       public static int nextInt() {
           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
        * between <code>0</code> (inclusive) and the specified value
        * (exclusive), from the Math.random() sequence.</p>
        *
        * @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) {
  +    
  +    /**
  +     * <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'
  -        return rnd.nextInt(n);
  +        return random.nextInt(n);
       }
  +    
       /**
        * <p>Returns the next pseudorandom, uniformly distributed long value
        * from the Math.random() sequence.</p>
  @@ -110,9 +133,18 @@
       public static long nextLong() {
           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
        * from the Math.random() sequence.</p>
  @@ -122,9 +154,18 @@
       public static boolean nextBoolean() {
           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
        * between <code>0.0</code> and <code>1.0</code> from the Math.random()
  @@ -135,19 +176,40 @@
       public static float nextFloat() {
           return nextFloat(JVM_RANDOM);
       }
  -    public static float nextFloat(Random rnd) {
  -        return rnd.nextFloat();
  +
  +    /**
  +     * <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>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 Math.random()
  +     * sequence.</p>
        *
        * @return the random double
        */
       public static double nextDouble() {
           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();
       }
       
   }
  
  
  
  1.6       +4 -2      
jakarta-commons/lang/src/java/org/apache/commons/lang/math/LongRange.java
  
  Index: LongRange.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/math/LongRange.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- LongRange.java    18 Aug 2003 02:22:24 -0000      1.5
  +++ LongRange.java    29 Dec 2003 00:58:27 -0000      1.6
  @@ -264,9 +264,11 @@
       }
   
       /**
  -     * <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>
  +     * 
  +     * @return the maximum number in this range cast to an <code>int</code>.
        */
       public int getMaximumInteger() {
           return (int) max;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to