com.rapidminer.tools
Class NumberParser
java.lang.Object
com.rapidminer.tools.NumberParser
public class NumberParser
- extends java.lang.Object
A heuristic number parser. That tries to analyze a given String in a more
flexible way than the traditional Java number parse:
1. All "," are replaced by "."
2. ¼,½,¾ are replaced by 0.25, 0.5, 0.75 respectively
3. Ranges ([number]-[number])are matched and the arithmetic average is used as result
4. All Prefixes and suffices are ignored
Example: "Weight: 8,5 - 10,5 g" would result in 9.5
- Author:
- Michael Wurst
|
Method Summary |
static double |
parse(java.lang.String s)
Parse a number possibly surrounded by other information. |
static double |
parseDouble(java.lang.String s)
This method parses the given string as double value. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
NumberParser
public NumberParser()
parse
public static double parse(java.lang.String s)
- Parse a number possibly surrounded by other information.
- Parameters:
s - the string
- Returns:
- a double representation or NaN if it cannot be parsed
parseDouble
public static double parseDouble(java.lang.String s)
throws java.lang.NumberFormatException
- This method parses the given string as double value.
It first tries the normal parse method, then tests if it is the ?
and would return NaN in this case.
Otherwise a NumberFormatExceptin is thrown.
- Throws:
java.lang.NumberFormatException
Copyright © 2001-2009 by Rapid-I