|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.ArrayList<FormulaVariable>
com.accountingenhancements.formula.FormulaVariableStack
public class FormulaVariableStack
An ordered list of FormulaVariable
s that represents a parsed Formula.
The formula is broken down into components separated by operators. The resulting stack is then processed first moving right until operator a leading operator has a greater precedence than the previous operator. Then the values are resolved and the math is solved working back toward the beginning of the stack until either the beginning of the stack or an operator of qreater precedence is encountered. Then the stack is scanned forward again.
The stack should alternate between Value type FormulaVariable
s and Operator type FormulaVariables
.
Field Summary | |
---|---|
protected java.lang.String |
formula
The formula that was handed into this class. |
protected int |
highestLevelInSolution
If this stack has been resolved then this is the highest level variable used in the solution. |
protected int |
lowestScale
|
protected FormulaVariable |
result
This is the result when the stack resolved. |
Fields inherited from class java.util.AbstractList |
---|
modCount |
Constructor Summary | |
---|---|
FormulaVariableStack()
Creates a new instance of FormulaVariableStack |
|
FormulaVariableStack(java.lang.String formula)
Creates a new instance of FormulaVariableStack |
Method Summary | |
---|---|
FormulaVariableStack |
clone()
|
FormulaVariable |
get(java.lang.String formulaVariableName)
|
void |
parseFormula(java.lang.String formula)
|
void |
purgeResultsInStackGreaterThanSpecifiedLevel(int specifiedLevel)
Go through entries in the stack and purge the results of any functions, formulas, or variable references, that used variables with a level higher than the specified level. |
void |
reparseFormula()
Reparse the formula that was last processed. |
FormulaVariable |
solve(FormulaVariableList variableList,
int iteration,
SupportParameters supportParameters,
FormulaFunctionList functionList)
This solves the supplied formula and returns the result. |
FormulaVariable |
solve(FormulaVariableList variableList,
int iteration,
SupportParameters supportParameters,
FormulaFunctionList functionList,
int resolveEverythingAboveLevel)
|
static FormulaVariable |
solveRangeOfValuesSeparatedBySameOperator(java.util.ArrayList<FormulaVariable> stack,
int startPointer,
int endPointer,
FormulaVariableList variableList,
SupportParameters supportParameters,
FormulaFunctionList functionList,
int resolveEverythingAboveLevel)
|
Methods inherited from class java.util.ArrayList |
---|
add, add, addAll, addAll, clear, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize |
Methods inherited from class java.util.AbstractList |
---|
equals, hashCode, iterator, listIterator, listIterator, subList |
Methods inherited from class java.util.AbstractCollection |
---|
containsAll, removeAll, retainAll, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.List |
---|
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList |
Field Detail |
---|
protected java.lang.String formula
protected FormulaVariable result
protected int highestLevelInSolution
protected int lowestScale
Constructor Detail |
---|
public FormulaVariableStack()
public FormulaVariableStack(java.lang.String formula) throws java.text.ParseException
formula
- the formula string that needs to be solved. This will be handed to FormulaVariableStack.parseFormula().
java.text.ParseException
Method Detail |
---|
public void parseFormula(java.lang.String formula) throws java.text.ParseException
formula
- the formula to be parsed. The old formula (if one exists) and old stack are cleared out.
java.text.ParseException
public void reparseFormula() throws java.text.ParseException
java.text.ParseException
public FormulaVariableStack clone()
clone
in class java.util.ArrayList<FormulaVariable>
public FormulaVariable solve(FormulaVariableList variableList, int iteration, SupportParameters supportParameters, FormulaFunctionList functionList) throws java.text.ParseException, java.lang.ClassNotFoundException
java.lang.ClassNotFoundException
- if part of solution requires solving a function that hasn't been added to the functionList
java.text.ParseException
public FormulaVariable solve(FormulaVariableList variableList, int iteration, SupportParameters supportParameters, FormulaFunctionList functionList, int resolveEverythingAboveLevel) throws java.lang.ArithmeticException, java.text.ParseException, java.lang.ClassNotFoundException
resolveEverythingAboveLevel
- resolves any solutions that incorporates variables with levels above this level. This saves time if a stack doesn't need to be resolved.
java.lang.ClassNotFoundException
- if part of solution requires solving a function that hasn't been added to the functionList
java.lang.ArithmeticException
java.text.ParseException
public static FormulaVariable solveRangeOfValuesSeparatedBySameOperator(java.util.ArrayList<FormulaVariable> stack, int startPointer, int endPointer, FormulaVariableList variableList, SupportParameters supportParameters, FormulaFunctionList functionList, int resolveEverythingAboveLevel) throws java.lang.ArithmeticException, java.text.ParseException, java.lang.ClassNotFoundException
java.lang.ArithmeticException
java.text.ParseException
java.lang.ClassNotFoundException
public FormulaVariable get(java.lang.String formulaVariableName)
public void purgeResultsInStackGreaterThanSpecifiedLevel(int specifiedLevel)
specifiedLevel
- the level above which all results are to be purged.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |