Class BooleanStringParser
java.lang.Object
com.martiansoftware.jsap.StringParser
com.martiansoftware.jsap.stringparsers.BooleanStringParser
A StringParser
for parsing Booleans. This StringParser is also used
internally
by the Switch class.
When parsing, the following arguments are interpreted as TRUE:
- null
- "t" (case-insensitive)
- "true" (case-insensitive)
- "y" (case-insensitive)
- "yes" (case-insensitive)
- "1"
The following arguments are interpreted as FALSE:
- "f" (case-insensitive)
- "false" (case-insensitive)
- "n" (case-insensitive)
- "no" (case-insensitive)
- "0"
All other input throws a ParseException.
- Author:
- Marty Lamb
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic BooleanStringParser
Returns aBooleanStringParser
.Converts the specified argument into a Boolean.Methods inherited from class com.martiansoftware.jsap.StringParser
setUp, tearDown
-
Constructor Details
-
BooleanStringParser
public BooleanStringParser()Deprecated.UsegetParser()
or, even better,JSAP.BOOLEAN_PARSER
.Creates a new BooleanStringParser
-
-
Method Details
-
getParser
Returns aBooleanStringParser
.Convenient access to the only instance returned by this method is available through
JSAP.BOOLEAN_PARSER
.- Returns:
- a
BooleanStringParser
.
-
parse
Converts the specified argument into a Boolean.When parsing, the following arguments are interpreted as TRUE:
- null
- "t" (case-insensitive)
- "true" (case-insensitive)
- "y" (case-insensitive)
- "yes" (case-insensitive)
- "1"
- "f" (case-insensitive)
- "false" (case-insensitive)
- "n" (case-insensitive)
- "no" (case-insensitive)
- "0"
The following arguments are interpreted as FALSE:
All other input throws a ParseException.
- Specified by:
parse
in classStringParser
- Parameters:
arg
- the argument to convert to a Boolean.- Returns:
- a Boolean as described above.
- Throws:
ParseException
- if none of the above cases are matched.
-
getParser()
or, even better,JSAP.BOOLEAN_PARSER
.