com::cosylab::gui::components::r2::FloatingPointParser Class Reference

Collaboration diagram for com::cosylab::gui::components::r2::FloatingPointParser:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 FloatingPointParser ()
synchronized final double parseDouble (String s) throws RuntimeException

Private Member Functions

final void doAction (int state, int symbol, char ch)
final int getNextSymbol (char ch)
final boolean parse (String s)

Private Attributes

String a = ""
String b = ""
String c = ""

Static Private Attributes

static final int ERROR_STATE = 99
static final int[][] transitions
static final
java.text.DecimalFormatSymbols 
symbols = new java.text.DecimalFormatSymbols()

Detailed Description

Simple, robust floating point number parser.

The parser is derived from the following regular expression:

[+-]?[0-9]*(\.[0-9]*)?((e[+-]?)[0-9]*)?

This expression allows maximum flexibility in description of floating point numbers, while still generating expected output. Every state of this parser is final and therefore suitable for parsing of sequential user input, where intermediate states are not valid values.

Creation date: (12/16/2001 16:46:23)

Author:
: Ales Pucelj (ales.pucelj@kgb.ijs.si)

Constructor & Destructor Documentation

com::cosylab::gui::components::r2::FloatingPointParser::FloatingPointParser (  )  [inline]

Creates new parser.


Member Function Documentation

final void com::cosylab::gui::components::r2::FloatingPointParser::doAction ( int  state,
int  symbol,
char  ch 
) [inline, private]

Performs action associated with each state. Creation date: (12/16/2001 17:04:50)

Parameters:
state int
ch Char

References a, b, and c.

Referenced by parse().

final int com::cosylab::gui::components::r2::FloatingPointParser::getNextSymbol ( char  ch  )  [inline, private]

Returns symbol based on character. Creation date: (12/16/2001 16:49:11)

Returns:
int
Parameters:
ch char

References symbols.

Referenced by parse().

final boolean com::cosylab::gui::components::r2::FloatingPointParser::parse ( String  s  )  [inline, private]

Performs the actual parsing. Creation date: (12/16/2001 16:48:37)

Returns:
boolean
Parameters:
s java.lang.String

References a, b, c, doAction(), ERROR_STATE, getNextSymbol(), and transitions.

Referenced by parseDouble().

synchronized final double com::cosylab::gui::components::r2::FloatingPointParser::parseDouble ( String  s  )  throws RuntimeException [inline]

Parses the supplied string and tries to convert it to double. Creation date: (12/16/2001 16:47:57)

Exceptions:
RuntimeException 
Returns:
double
Parameters:
s java.lang.String

References a, b, c, and parse().

Referenced by com::cosylab::gui::components::r2::JDoubleTextField::DoubleDocument::insertString(), and com::cosylab::gui::components::r2::JDoubleTextField::DoubleDocument::remove().


Member Data Documentation

Referenced by doAction(), parse(), and parseDouble().

Referenced by doAction(), parse(), and parseDouble().

Referenced by doAction(), parse(), and parseDouble().

Referenced by parse().

final java.text.DecimalFormatSymbols com::cosylab::gui::components::r2::FloatingPointParser::symbols = new java.text.DecimalFormatSymbols() [static, private]

Referenced by getNextSymbol().

Initial value:
 { 
            { 99,  1,  1,  2,  3 }, 
            { 99, 99,  1,  2,  3 }, 
            { 99, 99,  2, 99,  3 }, 
            { 99,  4,  4, 99, 99 }, 
            { 99, 99,  4, 99, 99 }
    }

Referenced by parse().


The documentation for this class was generated from the following file:

Generated by  doxygen 1.6.2