Class CharacterStringParser

  extended bycom.martiansoftware.jsap.StringParser
      extended bycom.martiansoftware.jsap.stringparsers.CharacterStringParser

public class CharacterStringParser
extends StringParser

A StringParser for 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.

Marty Lamb
See Also:
StringParser, Character

Constructor Summary
          Deprecated. Use getParser() or, even better, JSAP.CHARACTER_PARSER.
Method Summary
static CharacterStringParser getParser()
          Returns a CharacterStringParser.
 Object parse(String arg)
          Parses the specified argument into a Character.
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

Constructor Detail


public CharacterStringParser()
Deprecated. Use getParser() or, even better, JSAP.CHARACTER_PARSER.

Creates a new CharacterStringParser.

Method Detail


public static CharacterStringParser getParser()
Returns a CharacterStringParser.

Convenient access to the only instance returned by this method is available through JSAP.CHARACTER_PARSER.

a CharacterStringParser.


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:
parse in class StringParser
arg - the argument to parse
a Character object with the value contained in the specified argument.
ParseException - if ( (arg==null) || (arg.length()!=1) )
See Also:
Character, StringParser.parse(String)

Copyright © 2002-2006, Martian Software, Inc.. All Rights Reserved.
For the latest version and documentation, please visit