Class 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:
  • Constructor Details

    • XAssign

      public XAssign()
      Constructor using Assign 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 Details

    • 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 in XAssign(boolean) then the rhigh hand side is preprocessed, but no action is taken on the lhs. If useEqn is true then if the lhs implements SymbolicLValueI calls SymbolicLValueI.setEqn(Jep, Node, Node).
      Specified by:
      process in interface CommandVisitorI
      Parameters:
      node - top node of the tree
      children - 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

      public 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 call
       pv.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 interface CallbackEvaluationI
      Parameters:
      node - The current node
      pv - 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

      public void run(Stack<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 its 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 interface PostfixMathCommandI
      Overrides:
      run in class PostfixMathCommand
      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 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:
      init in interface JepComponent
      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 interface JepComponent
      Returns:
      either a new instance, null or 'this'.