com.singularsys.jep.misc.lineNumbering

## Class LineNumberingNodeFactory

- java.lang.Object
- - com.singularsys.jep.NodeFactory
  - - com.singularsys.jep.misc.lineNumbering.LineNumberingNodeFactory

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

      public class LineNumberingNodeFactory
      extends NodeFactory

  A NodeFactory which adds line numbering information to nodes. The method `setCurrentPosition(int,int)` is used to set the position before calling one of the `buildConstantNode(Object value)` methods. This stores the line and column numbers in the created node using the `Node.setHook(Node.HookKey,Object)` method. The `getLineNumber(Node)` and `getColumn(Node)` class methods can be used to retrieve this information from a given node. By convention, numbering starts from line 1 column 1.
  Since:
    3.4.0
  See Also:
    `LineNumberingShuntingYard`, Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `LineNumberingNodeFactory.Numbering`

  - ### Field Summary

    - ### Fields inherited from class com.singularsys.jep.NodeFactory

      `ev, j, vt`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `LineNumberingNodeFactory()` Default constructor which decorates a NodeFactory.
    `LineNumberingNodeFactory(NodeFactory root)` Decorating constructor

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `ASTConstant` | `buildConstantNode(ASTConstant node)` Create an ASTConstant with same value as argument
    `ASTConstant` | `buildConstantNode(java.lang.Object value)` Creates an ASTConstant node with specified value.
    `ASTConstant` | `buildConstantNode(Operator op, Node... children)` Creates a ASTConstant whose value of applying the operator to its arguments.
    `ASTConstant` | `buildConstantNode(PostfixMathCommandI pfmc, Node... children)` Creates a constant node whose result is the given function applied to the children.
    `ASTFunNode` | `buildFunctionNode(ASTFunNode node, Node... arguments)` Builds a function with n arguments and same fun as specified in arguments.
    `ASTFunNode` | `buildFunctionNode(java.lang.String name, PostfixMathCommandI pfmc, Node... arguments)` Builds a function with n arguments.
    `ASTOpNode` | `buildOperatorNode(Operator op, Node... arguments)` Builds a operator node with n arguments This method should be sub-classed.
    `ASTOpNode` | `buildUnfinishedOperatorNode(Operator op)` An unfinished node.
    `ASTVarNode` | `buildVariableNode(ASTVarNode node)` creates a new ASTVarNode with the same name as argument.
    `ASTVarNode` | `buildVariableNode(java.lang.String name)` Build a variable node when just the name is known.
    `ASTVarNode` | `buildVariableNode(Variable var)` creates a new ASTVarNode with a given variable.
    `ASTVarNode` | `buildVariableNodeCheckUndeclared(java.lang.String name)` Build a variable node checking for the undeclared status.
    `static int` | `getColumn(Node node)` Convenience method to get the column number of a node.
    `int` | `getCurrentColumn()` Gets the current column used when a node is created.
    `int` | `getCurrentLine()` Gets the current line used when a node is created.
    `JepComponent` | `getLightWeightInstance()` Gets a light-weight instance suitable for using in multiple threads.
    `static int` | `getLineNumber(Node node)` Convenience method to get the line number of a node.
    `NodeFactory` | `getRoot()`
    `void` | `init(Jep jep)` Initialize the component.
    `void` | `setCurrentPosition(int line, int col)` Sets the current position which will be used the next time a node is created.
    `static void` | `setPosition(Node node, int line, int col)` Convenience method to set the line and column numbers for a node.

    - ### Methods inherited from class com.singularsys.jep.NodeFactory

      `copyChildren`

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

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

- - ### Constructor Detail

    - #### LineNumberingNodeFactory

          public LineNumberingNodeFactory(NodeFactory root)

      Decorating constructor
      Parameters:
        `root` -

    - #### LineNumberingNodeFactory

          public LineNumberingNodeFactory()

      Default constructor which decorates a NodeFactory.

  - ### Method Detail

    - #### getLineNumber

          public static int getLineNumber(Node node)

      Convenience method to get the line number of a node.
      Parameters:
        `node` -
      Returns:
        the line number

    - #### getColumn

          public static int getColumn(Node node)

      Convenience method to get the column number of a node.
      Parameters:
        `node` -
      Returns:
        the column number

    - #### setPosition

          public static void setPosition(Node node,
                                         int line,
                                         int col)

      Convenience method to set the line and column numbers for a node.
      Parameters:
        `node` - who's position will be set
        `line` - line number
        `col` - column number

    - #### setCurrentPosition

          public void setCurrentPosition(int line,
                                         int col)

      Sets the current position which will be used the next time a node is created.
      Parameters:
        `line` -
        `col` -

    - #### getCurrentLine

          public int getCurrentLine()

      Gets the current line used when a node is created.
      Returns:
        the current line

    - #### getCurrentColumn

          public int getCurrentColumn()

      Gets the current column used when a node is created.
      Returns:
        the current column

    - #### buildConstantNode

          public ASTConstant buildConstantNode(ASTConstant node)
                                        throws ParseException

      Description copied from class: `NodeFactory`
      Create an ASTConstant with same value as argument. *
      Overrides:
        `buildConstantNode` in class `NodeFactory`
      Throws:
        `ParseException`

    - #### buildConstantNode

          public ASTConstant buildConstantNode(java.lang.Object value)
                                        throws ParseException

      Description copied from class: `NodeFactory`
      Creates an ASTConstant node with specified value. This method should be overwritten by subclasses.
      Overrides:
        `buildConstantNode` in class `NodeFactory`
      Throws:
        `ParseException`

    - #### buildConstantNode

          public ASTConstant buildConstantNode(Operator op,
                                               Node... children)
                                        throws ParseException

      Description copied from class: `NodeFactory`
      Creates a ASTConstant whose value of applying the operator to its arguments.
      Overrides:
        `buildConstantNode` in class `NodeFactory`
      Throws:
        `ParseException`

    - #### buildConstantNode

          public ASTConstant buildConstantNode(PostfixMathCommandI pfmc,
                                               Node... children)
                                        throws ParseException

      Description copied from class: `NodeFactory`
      Creates a constant node whose result is the given function applied to the children. This method replaces non varargs methods in Jep 3.4
      Overrides:
        `buildConstantNode` in class `NodeFactory`
      Parameters:
        `pfmc` - the function to apply
        `children` - the arguments to the function, each argument should be a constant node.
      Returns:
        a new constant node
      Throws:
        `ParseException`

    - #### buildFunctionNode

          public ASTFunNode buildFunctionNode(ASTFunNode node,
                                              Node... arguments)
                                       throws ParseException

      Description copied from class: `NodeFactory`
      Builds a function with n arguments and same fun as specified in arguments.
      Overrides:
        `buildFunctionNode` in class `NodeFactory`
      Parameters:
        `node` - the properties (name and pfmc) of this node will be copied.
        `arguments` - the arguments to the function.
      Returns:
        top Node of expression
      Throws:
        `ParseException`

    - #### buildFunctionNode

          public ASTFunNode buildFunctionNode(java.lang.String name,
                                              PostfixMathCommandI pfmc,
                                              Node... arguments)
                                       throws ParseException

      Description copied from class: `NodeFactory`
      Builds a function with n arguments. Subclasses should override this method.
      Overrides:
        `buildFunctionNode` in class `NodeFactory`
      Parameters:
        `name` - of function.
        `pfmc` - PostfixMathCommand for function.
        `arguments` - the arguments to the function.
      Returns:
        top Node of expression
      Throws:
        `ParseException`

    - #### buildOperatorNode

          public ASTOpNode buildOperatorNode(Operator op,
                                             Node... arguments)
                                      throws ParseException

      Description copied from class: `NodeFactory`
      Builds a operator node with n arguments This method should be sub-classed. This varargs method replaces corresponding non varargs methods from Jep 3.4
      Overrides:
        `buildOperatorNode` in class `NodeFactory`
      Parameters:
        `op` - the operator to use
        `arguments` - the arguments to the function.
      Returns:
        top Node of expression
      Throws:
        `ParseException`

    - #### buildUnfinishedOperatorNode

          public ASTOpNode buildUnfinishedOperatorNode(Operator op)

      Description copied from class: `NodeFactory`
      An unfinished node. Caller has responsibility for filling in the children.
      Overrides:
        `buildUnfinishedOperatorNode` in class `NodeFactory`

    - #### buildVariableNode

          public ASTVarNode buildVariableNode(ASTVarNode node)
                                       throws ParseException

      Description copied from class: `NodeFactory`
      creates a new ASTVarNode with the same name as argument.
      Overrides:
        `buildVariableNode` in class `NodeFactory`
      Throws:
        `ParseException`

    - #### buildVariableNode

          public ASTVarNode buildVariableNode(java.lang.String name)
                                       throws ParseException

      Description copied from class: `NodeFactory`
      Build a variable node when just the name is known.
      Overrides:
        `buildVariableNode` in class `NodeFactory`
      Parameters:
        `name` - the name of the variable
      Returns:
        the node created
      Throws:
        `ParseException`

    - #### buildVariableNode

          public ASTVarNode buildVariableNode(Variable var)
                                       throws ParseException

      Description copied from class: `NodeFactory`
      creates a new ASTVarNode with a given variable. This method should be sub-classed
      Overrides:
        `buildVariableNode` in class `NodeFactory`
      Throws:
        `ParseException`

    - #### buildVariableNodeCheckUndeclared

          public ASTVarNode buildVariableNodeCheckUndeclared(java.lang.String name)
                                                      throws ParseException

      Description copied from class: `NodeFactory`
      Build a variable node checking for the undeclared status.
      Overrides:
        `buildVariableNodeCheckUndeclared` in class `NodeFactory`
      Parameters:
        `name` - name of the variable
      Returns:
        a new node
      Throws:
        `ParseException` - if undeclared variables are not allowed and the variable does not exist

    - #### 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`
      Overrides:
        `getLightWeightInstance` in class `NodeFactory`
      Returns:
        new NodeFactory()

    - #### init

          public void init(Jep jep)

      Description copied from interface: `JepComponent`
      Initialize the component. This methods 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`
      Overrides:
        `init` in class `NodeFactory`
      Parameters:
        `jep` - the current Jep instance

    - #### getRoot

          public NodeFactory getRoot()

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