public class AlphaCode
extends java.lang.Object
| Constructor and Description |
|---|
AlphaCode() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
format(java.lang.String code)
Formats an alphanumeric code in groups of characters separated by hyphens, for instance a
16-character code is formatted as XXXX-XXXX-XXXX-XXXX.
|
static java.lang.String |
format(java.lang.String code,
int nGroups)
Formats an alphanumeric code in groups, for instance a 16-character code into 4 groups is
formatted as XXXX-XXXX-XXXX-XXXX.
|
static java.lang.String |
generate()
Generates an alphanumeric code with the default size (see property DefaultSize).
|
static java.lang.String |
generate(int codeSize)
Generates an alphanumeric code with the given size.
|
static int |
getDefaultSize()
Gets the default size for codes (used by the method generate()).
|
static java.lang.String |
parse(java.lang.String formattedCode)
Parses a given alphanumeric code, removing hyphens or other punctuations.
|
static void |
setDefaultSize(int defaultSize)
Sets the default size for codes (used by the method generate()).
|
public static java.lang.String generate()
public static java.lang.String generate(int codeSize)
codeSize - Size of the code to be generated.public static java.lang.String format(java.lang.String code)
code - The unformatted alphanumeric code.public static java.lang.String format(java.lang.String code,
int nGroups)
code - The unformatted alphanumeric code.nGroups - The number of groups.public static java.lang.String parse(java.lang.String formattedCode)
formattedCode - The formatted alphanumeric code, e.g. XXXX-XXXX-XXXX-XXXX.public static int getDefaultSize()
public static void setDefaultSize(int defaultSize)
defaultSize - the default size for codes (used by the method generate()).