|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.limitless.util.RandomStringGenerator
public class RandomStringGenerator
A quick way to get a random string of letters and numbers (without strength needed for strong cryptographic implementations). Typical usages:
String result = RandomStringGenerator.Instance().get(); RandomStringGenerator gen = new RandomStringGenerator(); String result2 = gen.get(); String big = gen.get( 200 ); // 200 byte string exactlyNOTE: Default size is between 10 and 20 bytes inclusive. The class is _meant_ to be over-ridden... The singleton is always a default implementation.
Resetting min size,
resetting max size,
reseting sequence of characters used| Field Summary | |
|---|---|
protected static int |
DefaultGrowthSize
default growth - the resulting string will always be at least min bytes long, but up to min+growth bytes -- the length is randomized as well. |
protected static int |
DefaultMinSize
default minimum string size for control of base class |
protected static java.lang.String |
letters
Default set of symbols |
(package private) static org.apache.log4j.Logger |
logger
Log4J Logger |
private java.util.Random |
random
This holds the random number generated used for the given object. |
private static RandomStringGenerator |
singletonInstance
The default instance to avoid object creation for the normal default case |
| Constructor Summary | |
|---|---|
RandomStringGenerator()
Create a default generator |
|
RandomStringGenerator(java.util.Random r)
Create with an existing source of random numbers for repeatable behavior |
|
| Method Summary | |
|---|---|
protected java.lang.String |
generate(int bytesInString)
The default generate routine chooses random characters from a provided string. |
java.lang.String |
get()
Fetch a random string with a random size between min and min + growth. |
java.lang.String |
get(int bytesInString)
Fetch a random string of bytesInString size _exactly_. |
protected int |
getGrowthSize()
This defines how much larger than min is allowed and can be over-ridden in the derived class |
protected int |
getMinSize()
This returns the smallest the string can be, and is allowed to be over-ridden in a derived class |
protected java.lang.String |
getSymbolSet()
This returns a string containing the only characters that will ever appear in the random set. |
static RandomStringGenerator |
Instance()
Singleton is used to access the "default" which avoids creation of objects. |
static void |
main(java.lang.String[] args)
Test entry, should spew random strings of the right lengths...pointless for "repeatable" testing, but a human being eyeballing the result should see "reasonable" different strings |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
static org.apache.log4j.Logger logger
protected static final java.lang.String letters
protected static final int DefaultMinSize
protected static final int DefaultGrowthSize
private static final RandomStringGenerator singletonInstance
private final java.util.Random random
| Constructor Detail |
|---|
public RandomStringGenerator()
public RandomStringGenerator(java.util.Random r)
| Method Detail |
|---|
public static RandomStringGenerator Instance()
public java.lang.String get()
public java.lang.String get(int bytesInString)
protected int getMinSize()
protected int getGrowthSize()
protected java.lang.String getSymbolSet()
protected java.lang.String generate(int bytesInString)
public static void main(java.lang.String[] args)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||