|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.martiansoftware.jsap.StringParser com.martiansoftware.jsap.stringparsers.EnumeratedStringParser
A StringParser
that enforces a limited set of String options for its
values.
These values are provided in the constructor together with one or two parameters
that control the processing of these values.
EnumeratedStringParser was generously contributed to JSAP by Klaus-Peter Berg of Siemens AG, Munich, Germany.
Field Summary | |
static char |
CONSTRUCTOR_VALUE_SEPARATOR
char used to separate enumerated values when they are supplied to the constructor |
Constructor Summary | |
EnumeratedStringParser(String validOptionValues)
Deprecated. use getParser(String) . |
|
EnumeratedStringParser(String validOptionValues,
boolean caseSensitive)
Deprecated. use getParser(String, boolean) . |
|
EnumeratedStringParser(String validOptionValues,
boolean caseSensitive,
boolean checkOptionChars)
Deprecated. use getParser(String, boolean, boolean) . |
Method Summary | |
static EnumeratedStringParser |
getParser(String validOptionValues)
Returns an EnumeratedParameterParser with parameter "caseSensitive" set to false and "checkOptionChars" set to true. |
static EnumeratedStringParser |
getParser(String validOptionValues,
boolean caseSensitive)
Returns an EnumeratedParameterParser with parameter "checkOptionChars" set to true. |
static EnumeratedStringParser |
getParser(String validOptionValues,
boolean caseSensitive,
boolean checkOptionChars)
Returns an EnumeratedParameterParser. |
Object |
parse(String arg)
Parses the specified argument, making sure it matches one of the valid options supplied to its constructor. |
Methods inherited from class com.martiansoftware.jsap.StringParser |
setUp, tearDown |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final char CONSTRUCTOR_VALUE_SEPARATOR
Constructor Detail |
public EnumeratedStringParser(String validOptionValues, boolean caseSensitive, boolean checkOptionChars) throws IllegalArgumentException
getParser(String, boolean, boolean)
.
validOptionValues
- a string that contains valid values for an option
in the format "value_1;value_2;..;value_n"; spaces between values are allowed
to make things more readable, e.g., "value_1; value_2";
option values have to be constructed using Java identifier characters
if the checkOptionChars parameter tells the parser to do this.caseSensitive
- tells the parser whether the option value is case sensitivecheckOptionChars
- tells the parser whether to check for Java identifier conformant characters.
IllegalArgumentException
- if the option value string has wrong format
or is emptypublic EnumeratedStringParser(String validOptionValues, boolean caseSensitive) throws IllegalArgumentException
getParser(String, boolean)
.
public EnumeratedStringParser(String validOptionValues) throws IllegalArgumentException
getParser(String)
.
Method Detail |
public static EnumeratedStringParser getParser(String validOptionValues, boolean caseSensitive, boolean checkOptionChars) throws IllegalArgumentException
validOptionValues
- a string that contains valid values for an option
in the format "value_1;value_2;..;value_n"; spaces between values are allowed
to make things more readable, e.g., "value_1; value_2";
option values have to be constructed using Java identifier characters
if the checkOptionChars parameter tells the parser to do this.caseSensitive
- tells the parser whether the option value is case sensitivecheckOptionChars
- tells the parser whether to check for Java identifier conformant characters.
IllegalArgumentException
- if the option value string has wrong format
or is emptypublic static EnumeratedStringParser getParser(String validOptionValues, boolean caseSensitive) throws IllegalArgumentException
validOptionValues
- a string that contains valid values for an option
in the format "value_1;value_2;..;value_n"; spaces between values are allowed
to make things more readable, e.g., "value_1; value_2";
option values have to be constructed using Java identifier characters.caseSensitive
- tells the parser wether the option value is case sensitive
IllegalArgumentException
- if the option value string has wrong format
or is emptypublic static EnumeratedStringParser getParser(String validOptionValues) throws IllegalArgumentException
validOptionValues
- a string that contains valid values for an option
in the format "value_1;value_2;..;value_n"; spaces between values are allowed
to make things more readable, e.g., "value_1; value_2";
option values have to be constructed using Java identifier characters.
IllegalArgumentException
- if the option value string has wrong format
or is emptypublic Object parse(String arg) throws ParseException
parse
in class StringParser
arg
- the argument to parse
ParseException
- if the specified argument cannot be parsed.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |