Package com.singularsys.extensions.xjep
Class XAssign
- java.lang.Object
-
- com.singularsys.jep.functions.PostfixMathCommand
-
- com.singularsys.extensions.xjep.XAssign
-
- All Implemented Interfaces:
CommandVisitorI
,CallbackEvaluationI
,JepComponent
,PostfixMathCommandI
,java.io.Serializable
public class XAssign extends PostfixMathCommand implements CallbackEvaluationI, CommandVisitorI, JepComponent
An assignment operator which implements the CommandVisitorI interface. When process is called the equation of the variable on the LHS is set to the RHS.- Author:
- Rich Morris Created on 18-Nov-2003
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class com.singularsys.jep.functions.PostfixMathCommand
curNumberOfParameters, name, NaN, numberOfParameters
-
-
Constructor Summary
Constructors Constructor Description XAssign()
Constructor usingAssign
for the basic evaluation method.XAssign(boolean useEqn)
Constructor to suppress copying of equations.XAssign(XJep jep, boolean b)
XAssign(CallbackEvaluationI root)
Decorator constructor using a specified function for evaluation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
evaluate(Node node, Evaluator pv)
Performs some special evaluation on the node.JepComponent
getLightWeightInstance()
Gets a light-weight instance suitable for using in multiple threads.void
init(Jep jep)
Initialize the component.boolean
isUseEquation()
Whether equations are used.Node
process(Node node, Node[] children)
In the pre-process stage, set the equation of the lhs variable to the rhs equation.void
run(java.util.Stack<java.lang.Object> aStack)
Throws an exception because this method should never be called under normal circumstances.-
Methods inherited from class com.singularsys.jep.functions.PostfixMathCommand
asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, checkNumberOfParameters, getName, getNumberOfParameters, setCurNumberOfParameters, setName, toString, toString
-
-
-
-
Constructor Detail
-
XAssign
public XAssign()
Constructor usingAssign
for the basic evaluation method.
-
XAssign
public XAssign(boolean useEqn)
Constructor to suppress copying of equations. Used when two different assignment operators are used, one for symbolic assignment and one which is only used for evaluation.- Parameters:
useEqn
- if false equations are never set
-
XAssign
public XAssign(CallbackEvaluationI root)
Decorator constructor using a specified function for evaluation.- Parameters:
root
- function used for evaluation
-
XAssign
public XAssign(XJep jep, boolean b)
-
-
Method Detail
-
process
public Node process(Node node, Node[] children) throws ParseException
In the pre-process stage, set the equation of the lhs variable to the rhs equation. If the useEqn flag is set inXAssign(boolean)
then the rhigh hand side is preprocessed, but no action is taken on the lhs. If useEqn is true then if the lhs implementsSymbolicLValueI
callsSymbolicLValueI.setEqn(Jep, Node, Node)
.- Specified by:
process
in interfaceCommandVisitorI
- Parameters:
node
- top node of the treechildren
- the children of the node after they have been preprocessed.- Returns:
- top node of the results.
- Throws:
ParseException
- if lhs is neither a variable or an LValue.
-
evaluate
public java.lang.Object evaluate(Node node, Evaluator pv) throws EvaluationException
Description copied from interface:CallbackEvaluationI
Performs some special evaluation on the node. This method has the responsibility for evaluating the children of the node and it should generally callpv.eval(node.jjtGetChild(i))
for each child. The SymbolTable is not passed as an argument. This is because it is better practice to get and set variable values by using node.getVar().setValue() rather that through the SymbolTable with requires a hashtable lookup.- Specified by:
evaluate
in interfaceCallbackEvaluationI
- Parameters:
node
- The current nodepv
- The visitor, can be used evaluate the children- Returns:
- the value after evaluation. This value will be passed to other functions higher up the node tree. The value can be any type including Double or Vector<Object>
- Throws:
EvaluationException
- if the calculation cannot be performed- See Also:
Evaluator
-
run
public void run(java.util.Stack<java.lang.Object> aStack) throws EvaluationException
Description copied from class:PostfixMathCommand
Throws an exception because this method should never be called under normal circumstances. Each function should use it's own run() method for evaluating the function. This includes popping off the parameters from the stack, and pushing the result back on the stack.- Specified by:
run
in interfacePostfixMathCommandI
- Overrides:
run
in classPostfixMathCommand
- Parameters:
aStack
- arguments for function- Throws:
EvaluationException
- if function cannot be evaluated
-
isUseEquation
public boolean isUseEquation()
Whether equations are used.- Returns:
-
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 interfaceJepComponent
- Parameters:
jep
- the current Jep instance
-
getLightWeightInstance
public JepComponent getLightWeightInstance()
Description copied from interface:JepComponent
Gets a light-weight instance suitable for using in multiple threads.- Specified by:
getLightWeightInstance
in interfaceJepComponent
- Returns:
- either an new instance, null or 'this'.
-
-