com.timjohnstondev.unitconverter.logic
Class FormulaParser
java.lang.Object
com.timjohnstondev.unitconverter.logic.FormulaParser
public final class FormulaParser
- extends Object
This parser can take a String as a formula that contains a variable (must be X) and the value for
that variable, do the calculations to return a BigDecimal.
There can be multiple occurrences of the variable, but only one variable. Symbols it can handle: (, ), ^,
*, /, +, -
|
Method Summary |
static BigDecimal |
parse(String variableValue,
String newFormula)
Returns the calculated value of the given formula with the variable value substituted in. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
parse
public static BigDecimal parse(String variableValue,
String newFormula)
- Returns the calculated value of the given formula with the variable value substituted in.
- Parameters:
variableValue - the value of the variable in the formulanewFormula - the formula to be evaluated
- Returns:
- the calculated value
Copyright © 2009 Tim Johnston Development, LLC. All Rights Reserved.