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 usingAssignfor 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.Objectevaluate(Node node, Evaluator pv)Performs some special evaluation on the node.JepComponentgetLightWeightInstance()Gets a light-weight instance suitable for using in multiple threads.voidinit(Jep jep)Initialize the component.booleanisUseEquation()Whether equations are used.Nodeprocess(Node node, Node[] children)In the pre-process stage, set the equation of the lhs variable to the rhs equation.voidrun(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 usingAssignfor 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 implementsSymbolicLValueIcallsSymbolicLValueI.setEqn(Jep, Node, Node).- Specified by:
processin 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:CallbackEvaluationIPerforms 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:
evaluatein 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 EvaluationExceptionDescription copied from class:PostfixMathCommandThrows 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:
runin interfacePostfixMathCommandI- Overrides:
runin 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:JepComponentInitialize 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:
initin interfaceJepComponent- Parameters:
jep- the current Jep instance
-
getLightWeightInstance
public JepComponent getLightWeightInstance()
Description copied from interface:JepComponentGets a light-weight instance suitable for using in multiple threads.- Specified by:
getLightWeightInstancein interfaceJepComponent- Returns:
- either an new instance, null or 'this'.
-
-