public class EnumeratedStringParser extends StringParser
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.
Modifier and Type | Field and Description |
---|---|
static char |
CONSTRUCTOR_VALUE_SEPARATOR
char used to separate enumerated values when they are supplied
to the constructor
|
Constructor and Description |
---|
EnumeratedStringParser(java.lang.String validOptionValues)
Deprecated.
use
getParser(String) . |
EnumeratedStringParser(java.lang.String validOptionValues,
boolean caseSensitive)
Deprecated.
|
EnumeratedStringParser(java.lang.String validOptionValues,
boolean caseSensitive,
boolean checkOptionChars)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
static EnumeratedStringParser |
getParser(java.lang.String validOptionValues)
Returns an EnumeratedParameterParser with parameter
"caseSensitive" set to false and "checkOptionChars" set to true.
|
static EnumeratedStringParser |
getParser(java.lang.String validOptionValues,
boolean caseSensitive)
Returns an EnumeratedParameterParser with parameter "checkOptionChars" set to true.
|
static EnumeratedStringParser |
getParser(java.lang.String validOptionValues,
boolean caseSensitive,
boolean checkOptionChars)
Returns an EnumeratedParameterParser.
|
java.lang.Object |
parse(java.lang.String arg)
Parses the specified argument, making sure it matches one of the valid
options supplied to its constructor.
|
setUp, tearDown
public static final char CONSTRUCTOR_VALUE_SEPARATOR
public EnumeratedStringParser(java.lang.String validOptionValues, boolean caseSensitive, boolean checkOptionChars) throws java.lang.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.java.lang.IllegalArgumentException
- if the option value string has wrong format
or is emptypublic EnumeratedStringParser(java.lang.String validOptionValues, boolean caseSensitive) throws java.lang.IllegalArgumentException
getParser(String, boolean)
.java.lang.IllegalArgumentException
public EnumeratedStringParser(java.lang.String validOptionValues) throws java.lang.IllegalArgumentException
getParser(String)
.java.lang.IllegalArgumentException
public static EnumeratedStringParser getParser(java.lang.String validOptionValues, boolean caseSensitive, boolean checkOptionChars) throws java.lang.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.java.lang.IllegalArgumentException
- if the option value string has wrong format
or is emptypublic static EnumeratedStringParser getParser(java.lang.String validOptionValues, boolean caseSensitive) throws java.lang.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 sensitivejava.lang.IllegalArgumentException
- if the option value string has wrong format
or is emptypublic static EnumeratedStringParser getParser(java.lang.String validOptionValues) throws java.lang.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.java.lang.IllegalArgumentException
- if the option value string has wrong format
or is emptypublic java.lang.Object parse(java.lang.String arg) throws ParseException
parse
in class StringParser
arg
- the argument to parseParseException
- if the specified argument cannot be parsed.Copyright © 2002-2006, Martian Software, Inc.. All Rights Reserved.
For the latest version and documentation, please visit http://www.martiansoftware.com/jsap