com.martiansoftware.jsap.stringparsers
Class IntegerStringParser

java.lang.Object
  extended bycom.martiansoftware.jsap.StringParser
      extended bycom.martiansoftware.jsap.stringparsers.IntegerStringParser

public class IntegerStringParser
extends StringParser

A StringParser for parsing Integers. The parse() method delegates the actual parsing to Integer.decode(String).

Author:
Marty Lamb
See Also:
StringParser, Integer

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

IntegerStringParser

public IntegerStringParser()
Deprecated. Use getParser() or, even better, JSAP.INTEGER_PARSER.

Creates a new IntegerStringParser.

Method Detail

getParser

public static IntegerStringParser getParser()
Returns a IntegerStringParser.

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

Returns:
a IntegerStringParser.

parse

public Object parse(String arg)
             throws ParseException
Parses the specified argument into an Integer. This method delegates the parsing to Integer.decode(arg). If Integer.decode() throws a NumberFormatException, it is encapsulated into a ParseException and re-thrown.

Specified by:
parse in class StringParser
Parameters:
arg - the argument to parse
Returns:
an Integer object with the value contained in the specified argument.
Throws:
ParseException - if Integer.decode(arg) throws a NumberFormatException.
See Also:
Integer, StringParser.parse(String)


Copyright © 2002-2006, Martian Software, Inc.. All Rights Reserved.
For the latest version and documentation, please visit http://www.martiansoftware.com/jsap