|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectthings.common.tools.Gamer
things.common.tools.TokenFactory
public class TokenFactory
A set of tools for creating tokens.
Version History
EPG - Initial, integrated from another project. - 26 NOV 04
EPG - Converted to use Gamer and added methods. - 11 AUG 06
Field Summary | |
---|---|
static char[] |
alphaCharacters
|
static char[] |
alphaNumericCharacters
|
static char[] |
alphaNumericCharactersLower
|
static char[] |
alphaNumericCharactersS
|
static char[] |
hexCharactersLower
|
static int |
MAX_SETS
The max sets allowed. |
static int |
MIN_SIZE
Smallest token possible. |
static char[] |
numericCharacters
|
Fields inherited from class things.common.tools.Gamer |
---|
rng |
Constructor Summary | |
---|---|
TokenFactory(int maxSize,
boolean highASCII,
boolean lowASCII)
Construct the factory. |
Method Summary | |
---|---|
char |
randomACharacter()
Get a random alpha character. |
java.lang.String |
randomHex()
Random hex token of random size. |
java.lang.String |
randomHex(int size)
Random hex token of a specific size. |
java.lang.String |
randomHexSets(int sets)
Random hex token of specified sets. |
char |
randomNCharacter()
Get a random numeric character. |
java.lang.String |
randomToken()
Get a random token of random size. |
java.lang.String |
randomToken(int size)
Get a random token of specified size. |
FlaggedString |
randomToken822(int spacePercentage,
int specialPecentage,
int quotablePercentage)
Get a random, flagged token appropriate for rfc822 fields (such as mail addresses) of specfied size. |
FlaggedString |
randomToken822(int size,
int spacePercentage,
int specialPercentage,
int quotablePercentage)
Get a random, flagged token appropriate for rfc822 fields (such as mail addresses) of specfied size. |
java.lang.String |
randomTokenAN()
Get a random alphanumeric token of random size. |
java.lang.String |
randomTokenAN(int size)
Random alphanumeric token of a specific size. |
java.lang.String |
randomTokenANS()
Random alphanumeric token of random size with a chance of spaces and a few benign punctuation. |
java.lang.String |
randomTokenANS(int size)
Random alphanumeric token of random size with a chance of spaces and a few benign punctuation of a specific size. |
java.lang.String |
randomTokenANSets(int sets)
Random alphanumeric token of specified sets. |
java.lang.String |
randomTokenBASE64(int size)
Create a random token of specified size with only valid BASE64 characters. |
java.lang.String |
randomTokenDNS()
Create a random token of random size with only valid DNS characters. |
java.lang.String |
randomTokenDNS(int size)
Create a random token of specified size with only valid DNS characters. |
java.lang.String |
randomTokenN()
Get a random numeric token of random size. |
java.lang.String |
randomTokenN(int size)
Random numeric token of a specific size. |
java.lang.String |
sentence(int maxWords,
int wordPercentChance,
int maxSize)
A sentence of randomly generated fake words. |
Methods inherited from class things.common.tools.Gamer |
---|
flipcoin, percent, pick, pickNumber, range |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int MAX_SETS
public static final int MIN_SIZE
public static final char[] alphaCharacters
public static final char[] numericCharacters
public static final char[] alphaNumericCharacters
public static final char[] alphaNumericCharactersS
public static final char[] alphaNumericCharactersLower
public static final char[] hexCharactersLower
Constructor Detail |
---|
public TokenFactory(int maxSize, boolean highASCII, boolean lowASCII)
maxSize
- maximum size of the token, must be at least 3. The minimum size is automatically 2.highASCII
- if true, it will include chars over 127lowASCII
- if true, it will include chars between 1 and 32 (inclusive)Method Detail |
---|
public java.lang.String randomToken()
public java.lang.String randomToken(int size)
size
- the size. If less than 1, it'll return an empty token. It will ignore the maxSize specified at construction.
public java.lang.String randomTokenAN()
public java.lang.String randomTokenAN(int size)
size
- the size. If less than 1, it'll return an empty token. It will ignore the maxSize specified at construction.
public java.lang.String randomTokenN()
public java.lang.String randomTokenN(int size)
size
- the size. If less than 1, it'll return an empty token. It will ignore the maxSize specified at construction.
public java.lang.String randomTokenANS()
public java.lang.String randomTokenANS(int size)
size
- the size. If less than 1, it'll return an empty token. It will ignore the maxSize specified at construction.
public java.lang.String randomTokenANSets(int sets)
sets
- the number of sets. If it is less than one or greater than MAX_SETS, it'll treat it as 1.
public java.lang.String randomHex()
public java.lang.String randomHex(int size)
size
- the size. If less than 1, it'll return an empty token. It will ignore the maxSize specified at construction.
public java.lang.String randomHexSets(int sets)
sets
- the number of sets. If it is less than one or greater than MAX_SETS, it'll treat it as 1.
public FlaggedString randomToken822(int spacePercentage, int specialPecentage, int quotablePercentage)
spacePercentage
- the percent chance for character that it'll be a space character.specialPecentage
- the percent chance for character that it'll be a 822 'special' character.quotablePercentage
- the percent chance for character that it'll be a 822 'quotable' character (besides spaces).
public FlaggedString randomToken822(int size, int spacePercentage, int specialPercentage, int quotablePercentage)
spacePercentage
- the percent chance for character that it'll be a space character.specialPercentage
- the percent chance for character that it'll be a 822 'special' character.quotablePercentage
- the percent chance for character that it'll be a 822 'quotable' character (besides spaces).
public java.lang.String randomTokenDNS()
public java.lang.String randomTokenDNS(int size)
size
- the size. If less than 1, it'll return an empty token. It will ignore the maxSize specified at construction.
public java.lang.String randomTokenBASE64(int size)
size
- the size. If less than 1, it'll return an empty token. It will ignore the maxSize specified at construction.
public java.lang.String sentence(int maxWords, int wordPercentChance, int maxSize)
maxWords
- absolute max wordswordPercentChance
- percent chance after each word that we'll do another word.maxSize
- maximum total size.
public char randomACharacter()
public char randomNCharacter()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |