
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() |
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)
| com::cosylab::gui::components::r2::FloatingPointParser::FloatingPointParser | ( | ) | [inline] |
Creates new parser.
| final void com::cosylab::gui::components::r2::FloatingPointParser::doAction | ( | int | state, | |
| int | symbol, | |||
| char | ch | |||
| ) | [inline, private] |
| final int com::cosylab::gui::components::r2::FloatingPointParser::getNextSymbol | ( | char | ch | ) | [inline, private] |
| 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)
| 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)
| RuntimeException |
| 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().
String com::cosylab::gui::components::r2::FloatingPointParser::a = "" [private] |
Referenced by doAction(), parse(), and parseDouble().
String com::cosylab::gui::components::r2::FloatingPointParser::b = "" [private] |
Referenced by doAction(), parse(), and parseDouble().
String com::cosylab::gui::components::r2::FloatingPointParser::c = "" [private] |
Referenced by doAction(), parse(), and parseDouble().
final int com::cosylab::gui::components::r2::FloatingPointParser::ERROR_STATE = 99 [static, private] |
Referenced by parse().
final java.text.DecimalFormatSymbols com::cosylab::gui::components::r2::FloatingPointParser::symbols = new java.text.DecimalFormatSymbols() [static, private] |
Referenced by getNextSymbol().
final int [][] com::cosylab::gui::components::r2::FloatingPointParser::transitions [static, private] |
{
{ 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().
1.6.2