Class CharacterStringParser
- java.lang.Object
-
- com.martiansoftware.jsap.StringParser
-
- com.martiansoftware.jsap.stringparsers.CharacterStringParser
-
public class CharacterStringParser extends StringParser
AStringParserfor parsing Characters. The parse() method requires an argument of length exactly equal to 1 in order to perform the conversion; otherwise, a ParseException is thrown.- Author:
- Marty Lamb
- See Also:
StringParser,Character
-
-
Constructor Summary
Constructors Constructor Description CharacterStringParser()Deprecated.UsegetParser()or, even better,JSAP.CHARACTER_PARSER.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static CharacterStringParsergetParser()Returns aCharacterStringParser.Objectparse(String arg)Parses the specified argument into a Character.-
Methods inherited from class com.martiansoftware.jsap.StringParser
setUp, tearDown
-
-
-
-
Constructor Detail
-
CharacterStringParser
public CharacterStringParser()
Deprecated.UsegetParser()or, even better,JSAP.CHARACTER_PARSER.Creates a new CharacterStringParser.
-
-
Method Detail
-
getParser
public static CharacterStringParser getParser()
Returns aCharacterStringParser.Convenient access to the only instance returned by this method is available through
JSAP.CHARACTER_PARSER.- Returns:
- a
CharacterStringParser.
-
parse
public Object parse(String arg) throws ParseException
Parses the specified argument into a Character. The conversion is performed by checking that the specified argument is exactly 1 character long, then encapsulating that char in a Character object. If the specified argument is not exactly 1 character long, a ParseException is thrown.- Specified by:
parsein classStringParser- Parameters:
arg- the argument to parse- Returns:
- a Character object with the value contained in the specified argument.
- Throws:
ParseException- if ( (arg==null) || (arg.length()!=1) )- See Also:
Character,StringParser.parse(String)
-
-