## net.percederberg.mib.asn1.node
Class Node

    java.lang.Object
      |
      +--net.percederberg.mib.asn1.node.Node

All Implemented Interfaces:
  NodeConstants, Switchable

Direct Known Subclasses:
  Production, Token

public abstract class Node
extends java.lang.Object
implements NodeConstants, Switchable

This abstract class is the interface for all the nodes in the parse tree.

Author:
  Per Cederberg, per@percederberg.net

Field Summary
`int` `kind` The kind of token.

Fields inherited from interface net.percederberg.mib.asn1.node.NodeConstants

`ALPHABETCONSTRAINT, ANYTYPE, ASSIGNMENT, ASSIGNMENTLIST, BINARYSTRING, BITSTRINGTYPE, BOOLEANVALUE, BUILTINTYPE, BUILTINVALUE, CHARSTRING, CHOICETYPE, CLASS, CLASSNUMBER, CONSTRAINT, CONSTRAINTLIST, DEFINEDMACRONAME, DEFINEDMACROTYPE, DEFINEDTYPE, DEFINEDVALUE, ELEMENTTYPE, ELEMENTTYPELIST, ENUMERATEDTYPE, EOF, EXPORTS, HEXSTRING, IDENTIFIER, IMPORTS, INTEGERTYPE, LOWERENDPOINT, MACROBODY, MACRODEFINITION, MACROREFERENCE, MODULEBODY, MODULEDEFINITION, MODULEIDENTIFIER, MODULEREFERENCE, NAMEANDNUMBERFORM, NAMEDNUMBER, NAMEDNUMBERLIST, NAMEDTYPE, NAMEDVALUE, NULLVALUE, NUMBER, OBJECTIDENTIFIERVALUE, OBJIDCOMPONENT, OBJIDCOMPONENTLIST, productionNodeName, SELECTIONTYPE, SEQUENCEOFTYPE, SEQUENCETYPE, SETOFTYPE, SETTYPE, SIGNEDNUMBER, SIZECONSTRAINT, SKIPTOEND, SNMPACCESSPART, SNMPDEFVALPART, SNMPDESCRPART, SNMPINDEXPART, SNMPOBJECTTYPEMACROTYPE, SNMPREFERPART, SNMPSTATUSPART, SNMPTRAPTYPEMACROTYPE, SNMPVARPART, SPECIALREALVALUE, START, STRINGTYPE, SYMBOL, SYMBOLLIST, SYMBOLSFROMMODULE, SYMBOLSFROMMODULELIST, TABSENT, TACCESS, TAG, TAGDEFAULT, TAGGEDTYPE, TANY, TAPPLICATION, TASSIGN, TBAR, TBEGIN, TBINSTRING, TBIT, TBOOLEAN, TBY, TCHOICE, TCOMMA, TCOMPONENT, TCOMPONENTS, TCSTRING, TDEFAULT, TDEFINED, TDEFINITIONS, TDEFVAL, TDESCRIPTION, TDOT, TEND, TENTERPRISE, TENUMERATED, TEXPLICIT, TEXPORTS, TFALSE, TFROM, THEXSTRING, TIDENTIFIER, TIMPLICIT, TIMPORTS, TINCLUDES, TINDEX, TINTEGER, TLCASEFIRST_IDENT, TLEFTBRACE, TLEFTBRACKET, TLEFTPAREN, TLESSTHAN, TMACRO, TMAX, TMIN, TMINUS, TMINUS_INFINITY, TNULL, TNUMBER, TOBJECT, TOBJECT_TYPE, TOCTET, TOF, tokenNodeName, TOPTIONAL, TPLUS_INFINITY, TPRESENT, TPRIVATE, TREAL, TREFERENCE, TRIGHTBRACE, TRIGHTBRACKET, TRIGHTPAREN, TSEMI_COLON, TSEQUENCE, TSET, TSIZE, TSTATUS, TSTRING, TSYNTAX, TTAGS, TTRAP_TYPE, TTRUE, TUCASEFIRST_IDENT, TUNIVERSAL, TVARIABLES, TWITH, TYPE, TYPEASSIGNMENT, TYPEORVALUE, TYPEORVALUELIST, TYPEREFERENCE, UPPERENDPOINT, VALUE, VALUEASSIGNMENT, VALUECONSTRAINT, VALUERANGE, VARTYPES`

Constructor Summary
`Node()`

Method Summary
`void` `apply(Switch sw)` Calls the relevant caseXXX method in the given switch.
`Node` `childAfter(Node child)` Returns the child coming after the given child.
`Node` `childAt(int index)` Returns a child with the given index.
`Node` `childOfType(int type)` Returns the first child of the given type.
`int` `children()` Returns the number of children to the current node.
`int` `childrenOfType(int type)` Returns the number of children of a given type to the current node.
`int` `firstColumn()` Finds the first column for the node.
`int` `firstLine()` Finds the first line for the node.
`Node` `getParent()` Returns the parent node of this node.
`boolean` `isAncestor(int type)` Checks if this node has an ancestor of the given type.
`boolean` `isParent(int type)` Checks if this node has a parent of the given type.
`boolean` `isType(int type)` Checks if this node is of the given type.
`int` `lastColumn()` Finds the last column for the node.
`int` `lastLine()` Finds the last line for the node.
`void` `setParent(Node parent)` Sets the given node as parent node to this node.
`static java.lang.String` `toName(int nodeType)` Returns the node name from the node type constant.
`static java.lang.String` `toName(Node node)` Returns the node name from the node object.
`java.lang.String` `toString()` Returns a string representation of this node.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### kind

    public int kind

  The kind of token. (Unfortunately this wasn't possible to make private since the parser uses it...)

Constructor Detail

### Node

    public Node()

Method Detail

### toName

    public static java.lang.String toName(int nodeType)

  Returns the node name from the node type constant. For undefined nodes null will be returned.
  Parameters:
    `nodeType` - a node type constant value
  Returns:
    a node name string

### toName

    public static java.lang.String toName(Node node)

  Returns the node name from the node object. For undefined nodes null will be returned.
  Parameters:
    `node` - a node object
  Returns:
    a node name string

### apply

    public void apply(Switch sw)

  Calls the relevant caseXXX method in the given switch.
  Specified by:
    `apply` in interface `Switchable`
  Parameters:
    `sw` - a switch object

### childAfter

    public Node childAfter(Node child)

  Returns the child coming after the given child.
  Parameters:
    `child` - a child node
  Returns:
    the next child, or null if no next child

### childAt

    public Node childAt(int index)

  Returns a child with the given index.
  Parameters:
    `index` - a child index, from 0 to children()-1
  Returns:
    a child node, or null

### childOfType

    public Node childOfType(int type)

  Returns the first child of the given type.
  Parameters:
    `type` - a node type constant value
  Returns:
    a child node, or null

### children

    public int children()

  Returns the number of children to the current node.
  Returns:
    the number of children, or zero for no children

### childrenOfType

    public int childrenOfType(int type)

  Returns the number of children of a given type to the current node.
  Parameters:
    `type` - the type number
  Returns:
    the number of children, or zero for no children

### getParent

    public Node getParent()

  Returns the parent node of this node.
  Returns:
    the parent node, or null for no parent

### isAncestor

    public boolean isAncestor(int type)

  Checks if this node has an ancestor of the given type.
  Parameters:
    `type` - a node type constant value
  Returns:
    true if some ancestor has the given type, false otherwise

### isParent

    public boolean isParent(int type)

  Checks if this node has a parent of the given type.
  Parameters:
    `type` - a node type constant value
  Returns:
    true if the parent has the given type, false otherwise

### isType

    public boolean isType(int type)

  Checks if this node is of the given type.
  Parameters:
    `type` - a node type constant value
  Returns:
    true if same type, otherwise false

### setParent

    public void setParent(Node parent)

  Sets the given node as parent node to this node.
  Parameters:
    `parent` - the node parent

### firstLine

    public int firstLine()

  Finds the first line for the node.
  Returns:
    the first line, or -1 if no token present

### firstColumn

    public int firstColumn()

  Finds the first column for the node.
  Returns:
    the first column, or -1 if no token present

### lastLine

    public int lastLine()

  Finds the last line for the node.
  Returns:
    the last line, or -1 if no token present

### lastColumn

    public int lastColumn()

  Finds the last column for the node.
  Returns:
    the last column, or -1 if no token present

### toString

    public java.lang.String toString()

  Returns a string representation of this node. Possible children will not be contained in this string. This method should be overridden by subclasses.
  Overrides:
    `toString` in class `java.lang.Object`
  Returns:
    a string representation of this node