org.apache.commons.lang
Class RandomStringUtils

java.lang.Object
  |
  +--org.apache.commons.lang.RandomStringUtils

public class RandomStringUtils
extends java.lang.Object

Common random String manipulation routines.

Originally from Turbine and the GenerationJavaCore library.

Version:
$Id: RandomStringUtils.java,v 1.1 2002/07/19 03:35:54 bayard Exp $
Author:
Jon S. Stevens, Daniel Rall, Greg Coladonato, Bayard, Ed Korthof, Steven Caswell, Stephen Colebourne

Field Summary
private static java.util.Random RANDOM
          Random object used by random method.
 
Constructor Summary
private RandomStringUtils()
          Prevent construction of RandomStringUtils instances
 
Method Summary
static java.lang.String random(int count)
          Creates a random string whose length is the number of characters specified.
static java.lang.String random(int count, boolean letters, boolean numbers)
          Creates a random string whose length is the number of characters specified.
static java.lang.String random(int count, char[] set)
          Creates a random string whose length is the number of characters specified.
static java.lang.String random(int count, int start, int end, boolean letters, boolean numbers)
          Creates a random string whose length is the number of characters specified.
static java.lang.String random(int count, int start, int end, boolean letters, boolean numbers, char[] set)
          Creates a random string based on a variety of options.
static java.lang.String random(int count, java.lang.String set)
          Creates a random string whose length is the number of characters specified.
static java.lang.String randomAlphabetic(int count)
          Creates a random string whose length is the number of characters specified.
static java.lang.String randomAlphanumeric(int count)
          Creates a random string whose length is the number of characters specified.
static java.lang.String randomAscii(int count)
          Creates a random string whose length is the number of characters specified.
static java.lang.String randomNumeric(int count)
          Creates a random string whose length is the number of characters specified.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

RANDOM

private static final java.util.Random RANDOM
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.
Constructor Detail

RandomStringUtils

private RandomStringUtils()
Prevent construction of RandomStringUtils instances
Method Detail

random

public static java.lang.String random(int count)
Creates a random string whose length is the number of characters specified. Characters will be chosen from the set of all characters.
Parameters:
count - length of random string to create
Returns:
the random string

randomAscii

public static java.lang.String randomAscii(int count)
Creates a random string whose length is the number of characters specified. Characters will be chosen from the set of characters whose ASCII value is between 32 and 127 .
Parameters:
count - length of random string to create
Returns:
the random string

randomAlphabetic

public static java.lang.String randomAlphabetic(int count)
Creates a random string whose length is the number of characters specified. Characters will be chosen from the set of alphabetic characters.
Parameters:
count - length of random string to create
Returns:
the random string

randomAlphanumeric

public static java.lang.String randomAlphanumeric(int count)
Creates a random string whose length is the number of characters specified. Characters will be chosen from the set of alpha-numeric characters.
Parameters:
count - length of random string to create
Returns:
the random string

randomNumeric

public static java.lang.String randomNumeric(int count)
Creates a random string whose length is the number of characters specified. Characters will be chosen from the set of numeric characters.
Parameters:
count - length of random string to create
Returns:
the random string

random

public static java.lang.String random(int count,
                                      boolean letters,
                                      boolean numbers)
Creates a random string whose length is the number of characters specified. Characters will be chosen from the set of alpha-numeric characters as indicated by the arguments.
Parameters:
count - length of random string to create
letters - if true, generated string will include alphabetic characters
numbers - if true, generatd string will include numeric characters
Returns:
the random string

random

public static java.lang.String random(int count,
                                      int start,
                                      int end,
                                      boolean letters,
                                      boolean numbers)
Creates a random string whose length is the number of characters specified. Characters will be chosen from the set of alpha-numeric characters as indicated by the arguments.
Parameters:
count - length of random string to create
start - int position in set of chars to start at
end - int position in set of chars to end before
letters - if true, generated string will include alphabetic characters
numbers - if true, generatd string will include numeric characters
Returns:
the random string

random

public static java.lang.String random(int count,
                                      int start,
                                      int end,
                                      boolean letters,
                                      boolean numbers,
                                      char[] set)
Creates a random string based on a variety of options.
Parameters:
count - int length of random string to create
start - int position in set of chars to start at
end - int position in set of chars to end before
letters - boolean only allow letters?
numbers - boolean only allow numbers?
set - char[] set of chars to choose randoms from. If null, then it will use the set of all chars.
Returns:
the random string

random

public static java.lang.String random(int count,
                                      java.lang.String set)
Creates a random string whose length is the number of characters specified. Characters will be chosen from the set of characters specified.
Parameters:
count - int length of random string to create
set - String containing the set of characters to use
Returns:
the random string

random

public static java.lang.String random(int count,
                                      char[] set)
Creates a random string whose length is the number of characters specified. Characters will be chosen from the set of characters specified.
Parameters:
count - int length of random string to create
set - character array containing the set of characters to use
Returns:
the random string


Copyright (c) 2001-2002 - Apache Software Foundation