public class Equ extends Object
You can also register your own functions and operators by calling the static methods registerFunction and registerOperator. These add to a static Map so there are then available for the duration of your application.
A support instance can be handed to an instance of Equ with the setSupport() method. This must be done prior to calling evaluate. When a variable is found in the equation (i.e.: not a known function, like x or myvar) then the support instance is asked to instantiate the variable. It is expected that it will do what is necessary to come up with it. The test cases show a support instance that maintains a local Map of variable name / value pairs. But a database could be used as well, for instance.
Modifier | Constructor and Description |
---|---|
protected |
Equ() |
public static Equ getInstance(EquationSupport support)
public static Equ getInstance()
public static Equ getInstance(boolean fresh)
public Object evaluate()
public Function function(TokVariable varTok)
public Date getBaseDate()
public org.apache.commons.codec.language.Metaphone getMetaphone()
public EquationSupport getSupport()
protected void initialize()
protected void initializeSupport()
protected List<EquPart> negatize(List<EquPart> equParts)
protected List<EquPart> rpnize(List<EquPart> oldTokens)
public void setBaseDate(Date newBaseDate)
public Equ setSupport(EquationSupport newSupport)
public String showRPN()
public void showRPN(StringBuilder sb)
public void unregisterFunction(String name)
public void unregisterOperator(String name)