commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scolebou...@apache.org
Subject cvs commit: jakarta-commons-sandbox/lang/src/java/org/apache/commons/lang Strings.java
Date Tue, 02 Jul 2002 00:18:11 GMT
scolebourne    2002/07/01 17:18:11

  Modified:    lang/src/java/org/apache/commons/lang Strings.java
  Log:
  Separate out RandomStrings
  
  Revision  Changes    Path
  1.10      +1 -87     jakarta-commons-sandbox/lang/src/java/org/apache/commons/lang/Strings.java
  
  Index: Strings.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/lang/src/java/org/apache/commons/lang/Strings.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Strings.java	2 Jul 2002 00:00:14 -0000	1.9
  +++ Strings.java	2 Jul 2002 00:18:10 -0000	1.10
  @@ -66,7 +66,6 @@
   
   import java.util.Iterator;
   import java.util.Map;
  -import java.util.Random;
   
   // CharSet
   import java.util.List;
  @@ -97,13 +96,6 @@
       public static int CHAR_BUFFER_SIZE = 4 * 1024;
   
       /**
  -     * Random object used by random method. This has to be not local 
  -     * to the random method so as to not return the same value in the 
  -     * same millisecond. 
  -     */
  -    private static Random RANDOM = new Random();
  -
  -    /**
        * Trims text safely, dealing with <code>null</code> references by
        * converting them to <code>""</code> (the empty string).
        *
  @@ -1756,84 +1748,6 @@
           }
   
           return str.substring(start, end);
  -    }
  -
  -
  -    static public String random(int count) {
  -        return random(count, false, false);
  -    }
  -
  -    static public String randomAscii(int count) {
  -        return random(count, 32, 127, false, false);
  -    }
  -    static public String randomAlphabetic(int count) {
  -        return random(count, true, false);
  -    }
  -    static public String randomAlphanumeric(int count) {
  -        return random(count, true, true);
  -    }
  -    static public String randomNumeric(int count) {
  -        return random(count, false, true);
  -    }
  -
  -    static public String random(int count, boolean letters, boolean numbers) {
  -        return random(count, 0, 0, letters, numbers);
  -    }
  -    static public String random(int count, int start, int end, boolean letters, boolean
numbers) {
  -        return random(count, start, end, letters, numbers, null);
  -    }
  -    /**
  -     * Create a random string based on a variety of options.
  -     *
  -     * @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.
  -     *
  -     */
  -    static public String random(int count, int start, int end, boolean letters, boolean
numbers, char[] set) {
  -        if( (start == 0) && (end == 0) ) {
  -            end = (int)'z';
  -            start = (int)' ';
  -            if(!letters && !numbers) {
  -                start = 0;
  -                end = Integer.MAX_VALUE;
  -            }
  -        }
  -
  -        StringBuffer buffer = new StringBuffer();
  -        int gap = end - start;
  -
  -        while(count-- != 0) {
  -            char ch;
  -            if(set == null) {
  -                ch = (char)(RANDOM.nextInt(gap) + start);
  -            } else {
  -                ch = set[RANDOM.nextInt(gap) + start];
  -            }
  -            if( (letters && numbers && Character.isLetterOrDigit(ch)) ||
  -                (letters && Character.isLetter(ch)) ||
  -                (numbers && Character.isDigit(ch)) ||
  -                (!letters && !numbers)
  -              ) 
  -            {
  -                buffer.append( ch );
  -            } else {
  -                count++;
  -            }
  -        }
  -        return buffer.toString();
  -    }
  -
  -    static public String random(int count, String set) {
  -        return random(count, set.toCharArray());
  -    }
  -
  -    static public String random(int count, char[] set) {
  -        return random(count,0,set.length-1,false,false,set);
       }
   
       static public String reverseDottedName(String text) {
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message