com.singularsys.jep.walkers

## Class ExpressionConsolidator

- java.lang.Object
- - com.singularsys.jep.walkers.DoNothingVisitor
  - - com.singularsys.jep.walkers.DeepCopyVisitor
    - - com.singularsys.jep.walkers.ExpressionConsolidator

- All Implemented Interfaces:
    JepComponent, ParserVisitor, java.io.Serializable

      public class ExpressionConsolidator
      extends DeepCopyVisitor

  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 and Description
    --- | ---
    `protected java.util.List<Operator>` | `ops`

    - ### Fields inherited from class com.singularsys.jep.walkers.DoNothingVisitor

      `ft, jep, nf, ot, vt`

  - ### Constructor Summary

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

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `add(Operator op)` Adds an addition operator to be consolidated.
    `Node` | `consolidate(Node node)`
    `protected Node[]` | `consolidateChildren(Operator op, 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.
    `java.util.List<Operator>` | `getOps()` The list of operators which are consolidated
    `java.lang.Object` | `visit(ASTOpNode node, java.lang.Object data)` Visit a operator node.

    - ### Methods inherited from class com.singularsys.jep.walkers.DeepCopyVisitor

      `deepCopy, visit, visit, visit`

    - ### Methods inherited from class com.singularsys.jep.walkers.DoNothingVisitor

      `childrenHaveChanged, copyChildrenIfNeeded, getFunctionTable, getLightWeightInstance, getNodeFactory, getOperatorTable, getVariableTable, init, visit, visitChildren, visitNode`

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

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

- - ### Field Detail

    - #### ops

          protected java.util.List<Operator> ops

  - ### Constructor Detail

    - #### ExpressionConsolidator

          public ExpressionConsolidator(Jep j)

      Default constructor, Add and Multiply are consolidated.
      Parameters:
        `j` -

  - ### Method Detail

    - #### consolidate

          public Node consolidate(Node node)
                           throws JepException

      Throws:
        `JepException`

    - #### consolidateChildren

          protected Node[] consolidateChildren(Operator op,
                                               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 java.lang.Object visit(ASTOpNode node,
                                        java.lang.Object data)
                                 throws JepException

      Description copied from class: `DoNothingVisitor`
      Visit a operator node. Can be overridden by sub-classes.
      Specified by:
        `visit` in interface `ParserVisitor`
      Overrides:
        `visit` in class `DeepCopyVisitor`
      Throws:
        `JepException`

    - #### add

          public boolean add(Operator op)

      Adds an addition operator to be consolidated.
      Parameters:
        `op` - operator to use
      Returns:
        true

    - #### getOps

          public java.util.List<Operator> getOps()

      The list of operators which are consolidated
      Returns:
        the list

Copyright © 2018 Singular Systems http://www.singularsys.com/jep