com.singularsys.jep.standard
Class FastEvaluator

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

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

See Also:
Serialized Form

Constructor Summary
FastEvaluator()
           
 
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 isTrapInfinity()
           
 boolean isTrapNaN()
           
 boolean isTrapNullValues()
          Whether null values for variables are trapped.
protected  java.lang.Object nodeAccept(Node node)
           
 void setTrapInfinity(boolean trapInfinity)
           
 void setTrapNaN(boolean trapNaN)
           
 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)
           
 java.lang.Object visitConstant(Node node)
           
protected  java.lang.Object visitFun(Node node)
          Visits a function/operator node.
 java.lang.Object visitVar(Node node)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FastEvaluator

public FastEvaluator()
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 - if errors occur during evaluation;

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 - if errors occur during evaluation;

nodeAccept

protected java.lang.Object nodeAccept(Node node)
                               throws EvaluationException
Throws:
EvaluationException

visit

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

visitConstant

public java.lang.Object visitConstant(Node node)
                               throws EvaluationException
Throws:
EvaluationException

visit

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

visitVar

public java.lang.Object visitVar(Node node)
                          throws EvaluationException
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(ASTOpNode node,
                              java.lang.Object data)
                       throws EvaluationException
Specified by:
visit in interface ParserVisitor
Throws:
EvaluationException

visitFun

protected java.lang.Object visitFun(Node 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 -

isTrapNaN

public boolean isTrapNaN()

setTrapNaN

public void setTrapNaN(boolean trapNaN)

isTrapInfinity

public boolean isTrapInfinity()

setTrapInfinity

public void setTrapInfinity(boolean trapInfinity)

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 FastEvaluator


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