public final class RandomWordGenerator
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static int |
GEN_DIGITS
Default random generator digits
|
static int |
GEN_LENGTH
Default random generator length.
|
static int |
GEN_SYMBOLS
Default random generator symbols
|
private static CentralLogger |
LOG
Logger
|
| Constructor and Description |
|---|
RandomWordGenerator() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
create()
Create a pseudorandom word using the default length, number of digits and symbol characters.
|
static java.lang.String |
create(int length,
int digits,
int symbols)
Create a pseudorandom word of the specified length, containing the specified number of digit
and symbol characters.
|
private static void |
fillRandomSlots(char[] buffer,
int number,
java.lang.String pool)
Using characters from the specified pool, randomly chosen, fill randomly chosen elements in
the given character buffer.
|
static void |
main(java.lang.String[] args)
Command line entry point to this class.
|
private static final CentralLogger LOG
public static final int GEN_LENGTH
public static final int GEN_DIGITS
public static final int GEN_SYMBOLS
public static java.lang.String create()
java.lang.IllegalArgumentException - if the specified number of digits and symbols combined exceeds the specified
length.public static java.lang.String create(int length,
int digits,
int symbols)
length - Length of the word; must be nonnegative and greater than or equal to the sum of
digits and symbols.digits - Number of digit characters required; will be ignored if less than 0.symbols - Number of symbol characters required; will be ignored if less than 0.java.lang.IllegalArgumentException - if the specified number of digits and symbols combined exceeds the specified
length.private static void fillRandomSlots(char[] buffer,
int number,
java.lang.String pool)
Implementation note: this algorithm is biased toward shorter words (i.e., tens to hundreds of characters). Performance degrades non-linearly with larger word lengths.
buffer - Buffer to populate.number - Number of fill characters to generate.pool - Pool of potential candidate characters from which to choose.java.lang.IllegalArgumentException - if number exceeds the buffer length.public static void main(java.lang.String[] args)
args - length - length of word to be generated
digits - number of digit characters to include in word
symbols - number of symbol characters to include in word