|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectlt.monarch.math.AbstractFormulaParser
lt.monarch.math.FormulaParser
public class FormulaParser extends AbstractFormulaParser
Parses the formula into the formula tree, which enables to calculate the value of the formula. The x0, x1, x2, x3, x4 and etc. are variables which can be used in the formula and the values of those can be supplied through eval method. In the eval method x0 corresponds to the first element in the array, x1 to the second and etc. Possible functions are: "sin", "cos", "tan", "asin", "acos", "atan", "abs", "exp", "log", "lg", "sqrt", "rad", "deg", "round", "floor", "ceil", "rnd". Also available statistical operations: "mean", "stdev", "variance", e.g. "mean(x0)*stdev(x0)" Possible constants are: "PI", "E". Numbers are double values. Possible operators are: "+", "-", "*", "/", "%", "^".
| Modifier and Type | Class and Description |
|---|
| Nested classes/interfaces inherited from class lt.monarch.math.AbstractFormulaParser |
|---|
AbstractFormulaParser.AbstractNode |
| Modifier and Type | Field and Description |
|---|---|
protected AbstractFormulaParser.AbstractNode |
rootNode
The root node, that starts the evaluation |
| Fields inherited from class lt.monarch.math.AbstractFormulaParser |
|---|
dataModel, nodeHash |
| Constructor and Description |
|---|
FormulaParser(java.lang.String formula)
Formula parser constructor |
| Modifier and Type | Method and Description |
|---|---|
void |
dispose()
Disposes the resources used by the class |
double |
eval()
Evaluates the value of the formula |
java.lang.Double |
eval(double value)
Evaluates the value of the formula |
java.lang.Double |
eval(java.lang.Double[] values)
Evaluates the value of the formula |
protected void |
finalize()
|
void |
setVariable(java.lang.String variableName,
int value)
Sets variable value |
protected void |
setVariables(java.lang.Double[] values)
Sets values of the variables |
| Methods inherited from class lt.monarch.math.AbstractFormulaParser |
|---|
getDataModel, setDataModel |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected AbstractFormulaParser.AbstractNode rootNode
| Constructor Detail |
|---|
public FormulaParser(java.lang.String formula)
throws java.lang.Exception
formula - Formula stringjava.lang.Exception - Exception if the error occurs while parsing the formula| Method Detail |
|---|
public double eval()
public java.lang.Double eval(double value)
throws java.lang.IllegalArgumentException
value - the variable value which corresponds to x1java.lang.IllegalArgumentException - Throws an exception if number of given values does not meet
the number of variables in the formula.
public java.lang.Double eval(java.lang.Double[] values)
throws java.lang.IllegalArgumentException
values - the values of variablesjava.lang.IllegalArgumentException - Throws an exception if number of given values does not meet
the number of variables in the formula.protected void setVariables(java.lang.Double[] values)
values - array of variable values
public void setVariable(java.lang.String variableName,
int value)
variableName - variable name. Possible names: index, row, columnvalue - variable valuepublic void dispose()
AbstractFormulaParser
dispose in class AbstractFormulaParser
protected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwable
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||