Does   :
public static String random(int count, int start, int end, boolean letters, 
boolean numbers, char[] set) 

really need to be public? Odds of correct use seem to be pretty low. It's a 
nice as a shared implementation, but it doesn't look like something that 
someone would really use.

Also, drawing and rejecting random characters can tail off forever. It's 
probablistic O(n), but the constant is proportional to the density of the 
allowed characters out of all characters. Something for the future. I didn't 
note this in the docs. Should I?





Index: RandomStringUtils.java
===================================================================
RCS file: /home/cvspublic/jakarta-commons/lang/src/java/org/apache/commons/lang/RandomStringUtils.java,v
retrieving revision 1.4
diff -U5 -w -r1.4 RandomStringUtils.java
--- RandomStringUtils.java	18 Sep 2002 19:53:52 -0000	1.4
+++ RandomStringUtils.java	28 Sep 2002 04:49:32 -0000
@@ -176,19 +176,27 @@
         return random(count, start, end, letters, numbers, null);
     }
     
     /**
      * Creates a random string based on a variety of options.
+	 * If start and end are both 0, start and end are set to ' ' and 'z', the ASCII
+	 * printable characters, will be used, unless letters and numbers are both 
+	 * false, in which case, start and end are set to 0 and Integer.MAX_VALUE.
+	 * <p>
+	 * If set is not null, characters between start and end are chosen.
+	 * <p>
      *
      * @param count int length of random string to create
      * @param start int position in set of chars to start at
      * @param end int position in set of chars to end before
      * @param letters boolean only allow letters?
      * @param numbers boolean only allow numbers?
      * @param set char[] set of chars to choose randoms from.
      *        If null, then it will use the set of all chars.
      * @return the random string
+     * @throws ArrayIndexOutOfBoundsException if there are not (end - start) + 1 
+     * characters in the set array.
      */
     public static String random(int count, int start, int end, boolean letters, boolean numbers, char[] set) {
         if( (start == 0) && (end == 0) ) {
             end = (int)'z';
             start = (int)' ';

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

Reply via email to