Package com.singularsys.jep.walkers

# Class ExpressionConsolidator

java.lang.Object
com.singularsys.jep.walkers.GenericDoNothingVisitor<Void>
com.singularsys.jep.walkers.GenericDeepCopyVisitor<Void>
com.singularsys.jep.walkers.ExpressionConsolidator

All Implemented Interfaces:
  `GenericVisitor<Node,Void,ParseException>`, `JepComponent`, `Serializable`

public class ExpressionConsolidator extends GenericDeepCopyVisitor<Void>
Consolidates nested addition and multiplication to produce nary operators. For example (x+y)+z -> +(x,y,z)

Author:
  Richard Morris
See Also:
  - Serialized Form

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected final List<Operator>`
  `ops`

  ### Fields inherited from class com.singularsys.jep.walkers.GenericDoNothingVisitor

  `ft, nf, ot`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ExpressionConsolidator(Jep j)`
  Default constructor, Add and Multiply are consolidated.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `add(Operator op)`
  Adds an addition operator to be consolidated.
  `Node`
  `consolidate(Node node)`
  `protected List<Node>`
  `consolidateChildren(Operator op, List<Node> children)`
  Creates an array of Nodes, if the child is an ASTOpNode whose operator is op, then the children of that child will be added otherwise the child is added.
  `List<Operator>`
  `getOps()`
  The list of operators which are consolidated
  `Node`
  `visit(ASTOpNode node, Void data)`
  Visit an operator node

  ### Methods inherited from class com.singularsys.jep.walkers.GenericDeepCopyVisitor

  `getLightWeightInstance, visit, visit, visit, visit`

  ### Methods inherited from class com.singularsys.jep.walkers.GenericDoNothingVisitor

  `childrenHaveChanged, copyChildrenIfNeeded, copyChildrenIfNeeded, init, makeException`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface com.singularsys.jep.GenericVisitor

  `makeException, visitChildren`

- ## Field Details

  - ### ops

    protected final List<Operator> ops

- ## Constructor Details

  - ### ExpressionConsolidator

    public ExpressionConsolidator(Jep j)
    Default constructor, Add and Multiply are consolidated.
    Parameters:
      `j` -

- ## Method Details

  - ### consolidate

    public Node consolidate(Node node) throws JepException
    Throws:
      `JepException`

  - ### consolidateChildren

    protected List<Node> consolidateChildren(Operator op, List<Node> children)
    Creates an array of Nodes, if the child is an ASTOpNode whose operator is op, then the children of that child will be added otherwise the child is added.
    Parameters:
      `op` -
      `children` -
    Returns:
      a new list of nodes

  - ### visit

    public Node visit(ASTOpNode node, Void data) throws ParseException
    Description copied from interface: `GenericVisitor`
    Visit an operator node
    Specified by:
      `visit` in interface `GenericVisitor<Node,Void,ParseException>`
    Overrides:
      `visit` in class `GenericDeepCopyVisitor<Void>`
    Parameters:
      `node` - current node
      `data` - context data
    Returns:
      the result of visiting the node
    Throws:
      `ParseException`

  - ### add

    public boolean add(Operator op)
    Adds an addition operator to be consolidated.
    Parameters:
      `op` - operator to use
    Returns:
      true

  - ### getOps

    public List<Operator> getOps()
    The list of operators which are consolidated
    Returns:
      the list