Package com.singularsys.jep.parser

# Interface Node

All Known Implementing Classes:
  `ASTConstant`, `ASTFunNode`, `ASTOpNode`, `ASTStart`, `ASTVarNode`, `SimpleNode`

public interface Node
Interface defining a node in the parse-tree.

All AST nodes must implement this interface. It provides basic machinery for constructing the parent and child relationships between nodes.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Interface
  Description
  `static interface`
  `Node.HookKey`
  Nodes can optional have hooks which add meta-data to the node.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Iterator<Node>`
  `childIterator()`
  Returns an Iterator which iterates over the children of the Node.
  `Iterable<Node>`
  `children()`
  Returns an Iterable object which can be used in a for/in loop.
  `Node[]`
  `getChildren()`
  Returns an array of the children of this node.
  `Object`
  `getHook(Node.HookKey key)`
  Get the object associated with the key
  `int`
  `getId()`
  Returns the numeric id of a node type. 2 = ASTOpNode, 3 = ASTVarNode, 4 = ASTFunNode, 5 = ASTConstant
  `String`
  `getName()`
  Return the name associated with the node (if any).
  `Operator`
  `getOperator()`
  Return the operator associated with a Node (if any)
  `PostfixMathCommandI`
  `getPFMC()`
  Return the pfmc of a node (if any)
  `Object`
  `getValue()`
  Return the value associated with the node (if any).
  `Variable`
  `getVar()`
  Return the variable associated with a Node (if any)
  `Collection<Node.HookKey>`
  `hookKeys()`
  Get all the keys defined for this node.
  `Object`
  `jjtAccept(ParserVisitor visitor, Object data)`
  Accept the visitor.
  `void`
  `jjtAddChild(Node n, int i)`
  This method tells the node to add its argument to the node's list of children.
  `void`
  `jjtClose()`
  This method is called after all the child nodes have been added.
  `Node`
  `jjtGetChild(int i)`
  This method returns a child node.
  `int`
  `jjtGetNumChildren()`
  Return the number of children the node has.
  `Node`
  `jjtGetParent()`
  Gets the parent node
  `void`
  `jjtOpen()`
  This method is called after the node has been made the current node.
  `void`
  `jjtSetParent(Node n)`
  Sets the parent node.
  `Object`
  `removeHook(Node.HookKey key)`
  Remove the key
  `Object`
  `setHook(Node.HookKey key, Object data)`
  Set the data associated with a given key

- ## Method Details

  - ### jjtOpen

    void jjtOpen()
    This method is called after the node has been made the current node. It indicates that child nodes can now be added to it.

  - ### jjtClose

    void jjtClose()
    This method is called after all the child nodes have been added.

  - ### jjtSetParent

    void jjtSetParent(Node n)
    Sets the parent node.

  - ### jjtGetParent

    Node jjtGetParent()
    Gets the parent node

  - ### jjtAddChild

    void jjtAddChild(Node n, int i)
    This method tells the node to add its argument to the node's list of children.

  - ### jjtGetChild

    Node jjtGetChild(int i)
    This method returns a child node. The children are numbered from zero, left to right.

  - ### jjtGetNumChildren

    int jjtGetNumChildren()
    Return the number of children the node has.
    Returns:
      the number of child nodes

  - ### jjtAccept

    Object jjtAccept(ParserVisitor visitor, Object data) throws JepException
    Accept the visitor.
    Throws:
      `JepException`

  - ### getValue

    Object getValue()
    Return the value associated with the node (if any).
    Returns:
      the value if an ASTConstant, ASTVarNode, null otherwise

  - ### getName

    String getName()
    Return the name associated with the node (if any).
    Returns:
      the name if an ASTVarNode, ASTFunNode, ASTOpNode, null otherwise

  - ### getPFMC

    PostfixMathCommandI getPFMC()
    Return the pfmc of a node (if any)
    Returns:
      the PostfixMathCommand for ASTFunNode and ASTOpNode, null otherwise

  - ### getOperator

    Operator getOperator()
    Return the operator associated with a Node (if any)
    Returns:
      The Operator for ASTOpNodes, null otherwise

  - ### getVar

    Variable getVar()
    Return the variable associated with a Node (if any)
    Returns:
      The Variable for ASTVarNodes, null otherwise

  - ### children

    Iterable<Node> children()
    Returns an Iterable object which can be used in a for/in loop.

         for(Node child:node.children()) {
          ...
         }

  - ### childIterator

    Iterator<Node> childIterator()
    Returns an Iterator which iterates over the children of the Node. The remove method is unsupported.
    Returns:
      a new Iterator

  - ### getId

    int getId()
    Returns the numeric id of a node type. 2 = ASTOpNode, 3 = ASTVarNode, 4 = ASTFunNode, 5 = ASTConstant
    See Also:
      - `JccParserTreeConstants`

  - ### setHook

    Object setHook(Node.HookKey key, Object data)
    Set the data associated with a given key
    Parameters:
      `key` - defining the type of data
      `data` - actual object
    Returns:
      previous object associated with the key

  - ### getHook

    Object getHook(Node.HookKey key)
    Get the object associated with the key
    Parameters:
      `key` -
    Returns:
      the object associated with the key

  - ### hookKeys

    Collection<Node.HookKey> hookKeys()
    Get all the keys defined for this node.
    Returns:
      all the keys

  - ### removeHook

    Object removeHook(Node.HookKey key)
    Remove the key
    Parameters:
      `key` -
    Returns:
      the object which was associated with the key

  - ### getChildren

    Node[] getChildren()
    Returns an array of the children of this node.
    Returns:
      an array of the children, or an empty array if there are no children
    Since:
      Jep 4.1