|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.ff.JEvaluator.JEvaluator
public class JEvaluator
| Field Summary | |
|---|---|
private java.util.HashMap<java.lang.String,JEvaluatorNodeBaseClass> |
evaluatorExprs
|
private java.util.HashMap<java.lang.String,BaseFunctionInterface> |
evaluatorFuncs
|
private java.util.HashMap<java.lang.String,java.lang.String> |
evaluatorNames
|
protected static org.apache.commons.logging.Log |
log
|
| Constructor Summary | |
|---|---|
JEvaluator()
|
|
JEvaluator(java.lang.String varEqualsExpr)
Creates an evaluator from an expression such as "varName=expr" |
|
JEvaluator(java.lang.String varName,
java.lang.String expr)
|
|
| Method Summary | |
|---|---|
protected java.util.List<java.lang.String> |
buildParamList(JEvaluatorNodeFunc f)
Computes function parameter values and builds list of "double" values to be later passed to the compute() method of the selected function |
protected java.lang.String |
compute(JEvaluatorNodeBaseClass n)
Recursively computes a subtree starting from the given rootNode |
private java.lang.String |
computeFunction(JEvaluatorNodeBaseClass n)
|
boolean |
delVar(java.lang.String varName)
Deletes a variable for the current evaluator instance |
void |
dump(java.lang.String varName)
|
private void |
exprCharDump(JEvaluatorExprChar[] exprChars,
int startPosition,
int endPosition)
|
private java.lang.String |
getExpressionRecursive(JEvaluatorNodeBaseClass n)
Recursively traverses this evaluator instance's tree, rebuilding the mathematical expression string for later printout |
java.lang.String |
getVar(java.lang.String varName)
Gets a variable's value for the current evaluator instance |
boolean |
init(java.lang.String configFile)
|
protected BaseFunctionInterface |
initFunctionClass(java.lang.String fName)
Instantiates a BaseFunctionInterface for later computation, based on the function's name |
boolean |
isFunctionRegistered(BaseFunctionInterface f)
Checks to see whether a function was registered |
boolean |
isFunctionRegistered(java.lang.String functionName)
Checks to see whether a function was registered |
boolean |
isVarDefined(java.lang.String varName)
Checks to see whether varName is defined for the current evaluator instance |
private JEvaluatorNodeBaseClass |
parse(java.lang.String expression)
Parses the specified mathematical expression |
private void |
recursiveDumper(JEvaluatorNodeBaseClass n)
|
private JEvaluatorNodeBaseClass |
recursiveParser(JEvaluatorExprChar[] exprChars,
int startPosition,
int endPosition)
Recursively parses the specified mathematical expression |
void |
registerFunction(BaseFunctionInterface f)
Registers a customized function to JEvaluator |
boolean |
setExpr(java.lang.String expression)
Sets a variable's value for the current evaluator instance, based on an expression in the format "varName=expression" |
boolean |
setVar(java.lang.String varName,
java.lang.String expr)
Sets a variable's value for the current evaluator instance |
void |
unregisterFunction(BaseFunctionInterface f)
Unregisters a customized function to JEvaluator |
boolean |
unregisterFunction(java.lang.String functionName)
Unregisters a customized function to JEvaluator |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static org.apache.commons.logging.Log log
private java.util.HashMap<java.lang.String,java.lang.String> evaluatorNames
private java.util.HashMap<java.lang.String,JEvaluatorNodeBaseClass> evaluatorExprs
private java.util.HashMap<java.lang.String,BaseFunctionInterface> evaluatorFuncs
| Constructor Detail |
|---|
public JEvaluator()
public JEvaluator(java.lang.String varName,
java.lang.String expr)
public JEvaluator(java.lang.String varEqualsExpr)
varEqualsExpr - | Method Detail |
|---|
public boolean init(java.lang.String configFile)
private void recursiveDumper(JEvaluatorNodeBaseClass n)
public void dump(java.lang.String varName)
private void exprCharDump(JEvaluatorExprChar[] exprChars,
int startPosition,
int endPosition)
private JEvaluatorNodeBaseClass recursiveParser(JEvaluatorExprChar[] exprChars,
int startPosition,
int endPosition)
exprChars - An evaluatorExprChar arraystartPosition - The leftmost evaluatorExprChar array element to considerendPosition - The number of items in the array
private JEvaluatorNodeBaseClass parse(java.lang.String expression)
expression - The expression to be parsed
private java.lang.String getExpressionRecursive(JEvaluatorNodeBaseClass n)
n - the root node
protected java.lang.String compute(JEvaluatorNodeBaseClass n)
throws java.lang.Exception
n - the rootNode
java.lang.Exception
private java.lang.String computeFunction(JEvaluatorNodeBaseClass n)
throws java.lang.Exception
java.lang.Exception
protected BaseFunctionInterface initFunctionClass(java.lang.String fName)
throws JEvaluatorException
fName - the function's name (sum, avg, ...)
JEvaluatorException
protected java.util.List<java.lang.String> buildParamList(JEvaluatorNodeFunc f)
throws java.lang.Exception
f - the evaluator node function
java.lang.Exceptionpublic boolean setExpr(java.lang.String expression)
expression - the expression in the format "varName=expression"
public boolean setVar(java.lang.String varName,
java.lang.String expr)
varName - the variable's nameexpr - the value/expression to set
public java.lang.String getVar(java.lang.String varName)
throws java.lang.Exception
varName - the variable name
java.lang.Exceptionpublic boolean delVar(java.lang.String varName)
varName - the variable name
public boolean isVarDefined(java.lang.String varName)
varName - the variable's name
public void registerFunction(BaseFunctionInterface f)
f - the Function object to registerpublic void unregisterFunction(BaseFunctionInterface f)
f - the Function object to unregisterpublic boolean unregisterFunction(java.lang.String functionName)
functionName - the Function object to unregister
public boolean isFunctionRegistered(BaseFunctionInterface f)
f - the function object
public boolean isFunctionRegistered(java.lang.String functionName)
functionName - the function name
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||