class Mnemonic
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
(package private) static int |
CASE_LOWER |
(package private) static int |
CASE_SENSITIVE |
(package private) static int |
CASE_UPPER |
private java.lang.String |
description |
private int |
max |
private boolean |
numericok |
private java.lang.String |
prefix |
private java.util.HashMap<java.lang.String,java.lang.Integer> |
strings |
private java.util.HashMap<java.lang.Integer,java.lang.String> |
values |
private int |
wordcase |
Constructor and Description |
---|
Mnemonic(java.lang.String description,
int wordcase)
Creates a new Mnemonic table.
|
Modifier and Type | Method and Description |
---|---|
void |
add(int val,
java.lang.String str)
Defines the text representation of a numeric value.
|
void |
addAlias(int val,
java.lang.String str)
Defines an additional text representation of a numeric value.
|
void |
addAll(Mnemonic source)
Copies all mnemonics from one table into another.
|
void |
check(int val)
Checks that a numeric value is within the range [0..max]
|
java.lang.String |
getText(int val)
Gets the text mnemonic corresponding to a numeric value.
|
int |
getValue(java.lang.String str)
Gets the numeric value corresponding to a text mnemonic.
|
private int |
parseNumeric(java.lang.String s) |
void |
remove(int val)
Removes both the numeric value and its text representation, including all aliases.
|
void |
removeAlias(java.lang.String str)
Removes an additional text representation of a numeric value.
|
private java.lang.String |
sanitize(java.lang.String str) |
void |
setMaximum(int max)
Sets the maximum numeric value
|
void |
setNumericAllowed(boolean numeric)
Sets whether numeric values stored in strings are acceptable.
|
void |
setPrefix(java.lang.String prefix)
Sets the prefix to use when converting to and from values that don't have mnemonics.
|
static final int CASE_SENSITIVE
static final int CASE_UPPER
static final int CASE_LOWER
private final java.util.HashMap<java.lang.String,java.lang.Integer> strings
private final java.util.HashMap<java.lang.Integer,java.lang.String> values
private final java.lang.String description
private final int wordcase
private java.lang.String prefix
private int max
private boolean numericok
public Mnemonic(java.lang.String description, int wordcase)
description
- A short description of the mnemonic to use whenwordcase
- Whether to convert strings into uppercase, lowercase, or leave them unchanged.
throwing exceptions.public void setMaximum(int max)
public void setPrefix(java.lang.String prefix)
public void setNumericAllowed(boolean numeric)
public void check(int val)
private java.lang.String sanitize(java.lang.String str)
private int parseNumeric(java.lang.String s)
public void add(int val, java.lang.String str)
val
- The numeric valuestr
- The text stringpublic void remove(int val)
val
- The numeric valuepublic void addAlias(int val, java.lang.String str)
val
- The numeric valuestr
- The text stringpublic void removeAlias(java.lang.String str)
str
- The text stringpublic void addAll(Mnemonic source)
source
- The source mnemonicjava.lang.IllegalArgumentException
- The wordcases of the Mnemonics do not match.public java.lang.String getText(int val)
val
- The numeric valuepublic int getValue(java.lang.String str)
str
- The text mnemonic