|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.github.cage.token.RandomTokenGenerator
public class RandomTokenGenerator
A simple random String generator that can be used to generate tokens for the captcha images. In its default mode instances of this class generate words from English lower cased letters where vowels and consonants are alternating.
Field Summary | |
---|---|
protected static int |
DEFAULT_TOKEN_LEN_DELTA
Default maximum length of token is DEFAULT_TOKEN_LEN_MIN +
2. |
protected static int |
DEFAULT_TOKEN_LEN_MIN
Default minimum length of token. |
Constructor Summary | |
---|---|
RandomTokenGenerator()
Constructor. |
|
RandomTokenGenerator(Random rnd)
Constructor. |
|
RandomTokenGenerator(Random rnd,
IGeneratorFactory<Character> characterGeneratorFactory,
int minLength,
int delta)
Constructor. |
|
RandomTokenGenerator(Random rnd,
int length)
Constructor. |
|
RandomTokenGenerator(Random rnd,
int minLength,
int delta)
Constructor. |
Method Summary | |
---|---|
IGeneratorFactory<Character> |
getCharacterGeneratorFactory()
|
int |
getDelta()
|
int |
getMinLength()
|
String |
next()
Returns an object with type T on every call. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final int DEFAULT_TOKEN_LEN_MIN
protected static final int DEFAULT_TOKEN_LEN_DELTA
DEFAULT_TOKEN_LEN_MIN
+
2.
Constructor Detail |
---|
public RandomTokenGenerator()
public RandomTokenGenerator(Random rnd)
rnd
- random generator to be used, can be nullpublic RandomTokenGenerator(Random rnd, int length)
length
- the length of the generated words, must be > 0rnd
- random generator to be used, can be nullpublic RandomTokenGenerator(Random rnd, int minLength, int delta)
rnd
- random generator to be used, can be nullminLength
- the minimum length of the generated words, must be > 0delta
- minLength + delta is the maximum length of the generated
words, delta must be >= 0public RandomTokenGenerator(Random rnd, IGeneratorFactory<Character> characterGeneratorFactory, int minLength, int delta)
rnd
- random generator to be used, can be nullcharacterGeneratorFactory
- character generator factory to be used for the actual
character creation, can be nullminLength
- the minimum length of the generated words, must be > 0delta
- minLength + delta is the maximum length of the generated
words, delta must be >= 0Method Detail |
---|
public String next()
IGenerator
T
on every call. The returned
object does not have to be a new instance.
next
in interface IGenerator<String>
public IGeneratorFactory<Character> getCharacterGeneratorFactory()
public int getMinLength()
public int getDelta()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |