public class Identifiers
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
BASE64_VALID_CHARS |
static java.lang.String |
ID_VALID_NONSTART_CHARS |
static java.lang.String |
ID_VALID_START_CHARS |
static java.lang.String |
JAVA_GENERATED_IDENTIFIER_START_CHARS |
static java.lang.String |
JAVA_GENERATED_IDENTIFIERNONSTART_CHARS |
static java.lang.String |
JAVA_GOOD_BINARY_REGEX
as
JAVA_GOOD_PACKAGE_OR_CLASS_REGEX but allowing a dollar sign inside a class name (e.g. |
static java.lang.String |
JAVA_GOOD_NONSTART_CHARS |
static java.lang.String |
JAVA_GOOD_PACKAGE_OR_CLASS_REGEX
regex for a java package or class name using "good" chars, that is no accents or funny unicodes.
|
static java.lang.String |
JAVA_GOOD_SEGMENT_REGEX |
static java.lang.String |
JAVA_GOOD_START_CHARS |
static java.lang.String |
LOWER_CASE_ALPHA |
static java.lang.String |
NON_ALPHA_NUMERIC |
static java.lang.String |
NUMERIC |
static java.lang.String |
PASSWORD_VALID_CHARS |
static java.lang.String |
UPPER_CASE_ALPHA |
Constructor and Description |
---|
Identifiers() |
Modifier and Type | Method and Description |
---|---|
static void |
appendBase64IdFromValueOfLength(long value,
int length,
java.lang.StringBuffer sb) |
static void |
appendBase64IdFromValueOfLength(long value,
int length,
java.lang.StringBuilder sb) |
static java.lang.String |
getBase64IdFromValue(long value) |
static java.lang.String |
getBase64IdFromValue(long value,
int length) |
static boolean |
isValidToken(java.lang.String token,
java.lang.String validStartChars,
java.lang.String validSubsequentChars) |
static java.lang.String |
makeIdFromHash(long d)
creates a short identifier comfortable in java and OS's, given an input hash code
|
static java.lang.String |
makeRandomBase64Id(int length) |
static java.lang.String |
makeRandomId(int l) |
static java.lang.String |
makeRandomJavaId(int l)
Makes a random id string (letters and numbers) of the given length;
starts with letter (upper or lower) so can be used as Java id.
|
static java.lang.String |
makeRandomLowercaseId(int l) |
static java.lang.String |
makeRandomPassword(int length) |
static java.lang.String |
makeRandomPassword(int length,
java.lang.String... passwordValidCharsPool)
A fairly slow but hopefully secure way to randomly select characters for a password
Takes a pool of acceptible characters using the first set in the pool for the first character,
second set for the second character, ..., nth set for all remaining character.
|
static boolean |
randomBoolean() |
static byte[] |
randomBytes(byte[] buf)
returns the array passed in
|
static byte[] |
randomBytes(int length) |
static double |
randomDouble() |
static int |
randomInt() |
static int |
randomInt(int upbound)
returns in [0,upbound)
|
static long |
randomLong() |
public static final java.lang.String UPPER_CASE_ALPHA
public static final java.lang.String LOWER_CASE_ALPHA
public static final java.lang.String NUMERIC
public static final java.lang.String NON_ALPHA_NUMERIC
public static final java.lang.String JAVA_GOOD_START_CHARS
public static final java.lang.String JAVA_GOOD_NONSTART_CHARS
public static final java.lang.String JAVA_GOOD_SEGMENT_REGEX
public static final java.lang.String JAVA_GOOD_PACKAGE_OR_CLASS_REGEX
public static final java.lang.String JAVA_GOOD_BINARY_REGEX
JAVA_GOOD_PACKAGE_OR_CLASS_REGEX
but allowing a dollar sign inside a class name (e.g. Foo$1)public static final java.lang.String JAVA_GENERATED_IDENTIFIER_START_CHARS
public static final java.lang.String JAVA_GENERATED_IDENTIFIERNONSTART_CHARS
public static final java.lang.String BASE64_VALID_CHARS
public static final java.lang.String ID_VALID_START_CHARS
public static final java.lang.String ID_VALID_NONSTART_CHARS
public static final java.lang.String PASSWORD_VALID_CHARS
public static java.lang.String makeRandomId(int l)
public static java.lang.String makeRandomLowercaseId(int l)
public static java.lang.String makeRandomPassword(int length)
length
- of password to be returnedpublic static java.lang.String makeRandomPassword(int length, java.lang.String... passwordValidCharsPool)
length
- length of passwordpasswordValidCharsPool
- pool of acceptable character setspublic static java.lang.String makeIdFromHash(long d)
result is always at least of length 1, shorter if the hash is smaller
public static java.lang.String makeRandomJavaId(int l)
public static double randomDouble()
public static long randomLong()
public static boolean randomBoolean()
public static int randomInt()
public static int randomInt(int upbound)
public static byte[] randomBytes(byte[] buf)
public static byte[] randomBytes(int length)
public static java.lang.String makeRandomBase64Id(int length)
public static java.lang.String getBase64IdFromValue(long value)
public static java.lang.String getBase64IdFromValue(long value, int length)
public static void appendBase64IdFromValueOfLength(long value, int length, java.lang.StringBuffer sb)
public static void appendBase64IdFromValueOfLength(long value, int length, java.lang.StringBuilder sb)
public static boolean isValidToken(java.lang.String token, java.lang.String validStartChars, java.lang.String validSubsequentChars)