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,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:
-
Field Summary
Fields inherited from class com.singularsys.jep.functions.PostfixMathCommand
curNumberOfParameters, description, name, NaN, numberOfParameters -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionPerforms some special evaluation on the node.Gets a light-weight instance suitable for using in multiple threads.voidInitialize the component.booleanWhether equations are used.In the pre-process stage, set the equation of the lhs variable to the rhs equation.voidThrows 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, asType, checkNumberOfParameters, getDescription, getDescription, getDescriptionWithType, getName, getNumberOfParameters, setCurNumberOfParameters, setDescription, setName, toString, toString
-
Constructor Details
-
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
Decorator constructor using a specified function for evaluation.- Parameters:
root- function used for evaluation
-
XAssign
-
-
Method Details
-
process
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 nor an LValue.
-
evaluate
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:
-
run
Description copied from class:PostfixMathCommandThrows an exception because this method should never be called under normal circumstances. Each function should use its ownrun()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
Description copied from interface:JepComponentInitialize the component. This method 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
Description copied from interface:JepComponentGets a light-weight instance suitable for using in multiple threads.- Specified by:
getLightWeightInstancein interfaceJepComponent- Returns:
- either a new instance, null or 'this'.
-