tcra.math
Class MathIntegerParser

java.lang.Object
  extended by tcra.math.MathTypeParser
      extended by tcra.math.MathIntegerParser

public class MathIntegerParser
extends MathTypeParser

MathIntegerParser is used to parse a MathInteger out of a String. If a valid integer can not be parsed, a MathFormatException is thrown. MathIntegerPaser follows the Singleton pattern since it is stateless and can save memory by only allowing one instance to exist.


Constructor Summary
MathIntegerParser()
           
 
Method Summary
 MathInteger parse(java.lang.StringBuilder input)
          Consumes all the characters from the front of a StringBuilder until it finds a ',' or '>'.
 
Methods inherited from class tcra.math.MathTypeParser
eatWhitespace, nextToken
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MathIntegerParser

public MathIntegerParser()
Method Detail

parse

public MathInteger parse(java.lang.StringBuilder input)
                  throws MathFormatException
Consumes all the characters from the front of a StringBuilder until it finds a ',' or '>'. Then Integer is used to convert the String into an integer.

Specified by:
parse in class MathTypeParser
Parameters:
input - StringBuilder that contains an integer at the front.
Returns:
MathInteger containing the integer value parsed and a reference to this MathIntegerParser.
Throws:
MathFormatException - If what is read is not a valid integer.