com.singularsys.jep.standard
Class StandardEvaluator

java.lang.Object
  extended by com.singularsys.jep.standard.StandardEvaluator
All Implemented Interfaces:
Evaluator, JepComponent, ParserVisitor, java.io.Serializable

public class StandardEvaluator
extends java.lang.Object
implements Evaluator, ParserVisitor

See Also:
Serialized Form

Constructor Summary
StandardEvaluator()
           
 
Method Summary
 java.lang.Object eval(Node node)
          Evaluates a sub expression.
 java.lang.Object evaluate(Node node)
          Evaluates a node and returns and object with the value of the node.
 JepComponent getLightWeightInstance()
          Gets a light-weight instance suitable for using in multiple threads.
 void init(Jep jep)
          Initialize the component.
 boolean isTrapNullValues()
          Whether null values for variables are trapped.
 void setTrapNullValues(boolean trapNullValues)
          Sets whether null values for variables are trapped.
 java.lang.Object visit(ASTConstant node, java.lang.Object data)
           
 java.lang.Object visit(ASTFunNode node, java.lang.Object data)
           
 java.lang.Object visit(ASTOpNode node, java.lang.Object data)
           
 java.lang.Object visit(ASTVarNode node, java.lang.Object data)
           
protected  void visitFun(ASTFunNode node)
          Visits a function/operator node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StandardEvaluator

public StandardEvaluator()
Method Detail

init

public void init(Jep jep)
Description copied from interface: JepComponent
Initialize the component. This methods is called whenever a component is added to Jep. Hence it allows components to keep track of the other components they may rely on.

Specified by:
init in interface JepComponent
Parameters:
jep - the current Jep instance

eval

public java.lang.Object eval(Node node)
                      throws EvaluationException
Description copied from interface: Evaluator
Evaluates a sub expression.

Specified by:
eval in interface Evaluator
Throws:
EvaluationException

evaluate

public java.lang.Object evaluate(Node node)
                          throws EvaluationException
Description copied from interface: Evaluator
Evaluates a node and returns and object with the value of the node.

Specified by:
evaluate in interface Evaluator
Throws:
EvaluationException

visit

public java.lang.Object visit(ASTConstant node,
                              java.lang.Object data)
                       throws EvaluationException
Specified by:
visit in interface ParserVisitor
Throws:
EvaluationException

visit

public java.lang.Object visit(ASTFunNode node,
                              java.lang.Object data)
                       throws EvaluationException
Specified by:
visit in interface ParserVisitor
Throws:
EvaluationException

visit

public java.lang.Object visit(ASTVarNode node,
                              java.lang.Object data)
                       throws EvaluationException
Specified by:
visit in interface ParserVisitor
Throws:
EvaluationException

visit

public java.lang.Object visit(ASTOpNode node,
                              java.lang.Object data)
                       throws EvaluationException
Specified by:
visit in interface ParserVisitor
Throws:
EvaluationException

visitFun

protected void visitFun(ASTFunNode node)
                 throws EvaluationException
Visits a function/operator node. This is the most visited method for most expression evaluations. Keeping it fast is important.

Parameters:
node -
Throws:
EvaluationException

isTrapNullValues

public boolean isTrapNullValues()
Whether null values for variables are trapped.

Returns:
the status if the trap null values flag.

setTrapNullValues

public void setTrapNullValues(boolean trapNullValues)
Sets whether null values for variables are trapped. If set (the default) then an EvaluationException is thrown for null values of variables. If not set then null values are passed to PostfixMathCommands who will need to test for null values.

Parameters:
trapNullValues -

getLightWeightInstance

public JepComponent getLightWeightInstance()
Description copied from interface: JepComponent
Gets a light-weight instance suitable for using in multiple threads.

Specified by:
getLightWeightInstance in interface JepComponent
Returns:
an new StandardEvaluator


Copyright © 2008 Singular Systems http://www.singularsys.com/jep