Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## 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:
  ParserVisitor

    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

Field Summary
`protected java.util.List<Operator>` | `ops`

Fields inherited from class com.singularsys.jep.walkers.DoNothingVisitor
`ft, jep, nf, ot, vt`

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

Method Summary
`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
`copyChildrenIfNeeded, 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

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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