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.

Version:
1.3
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, COMPLIANCEGROUP, COMPLIANCEOBJECT, CONSTRAINT, CONSTRAINTLIST, DEFINEDMACRONAME, DEFINEDMACROTYPE, DEFINEDTYPE, DEFINEDVALUE, ELEMENTTYPE, ELEMENTTYPELIST, ENUMERATEDTYPE, EOF, EXPORTS, HEXSTRING, IDENTIFIER, IMPORTS, INTEGERTYPE, LOWERENDPOINT, MACROBODY, MACRODEFINITION, MACROREFERENCE, MODULEBODY, MODULEDEFINITION, MODULEIDENTIFIER, MODULEREFERENCE, NAMEANDNUMBERFORM, NAMEDBIT, NAMEDBITS, NAMEDNUMBER, NAMEDNUMBERLIST, NAMEDTYPE, NAMEDVALUE, NULLVALUE, NUMBER, OBJECTIDENTIFIERVALUE, OBJIDCOMPONENT, OBJIDCOMPONENTLIST, productionNodeName, SELECTIONTYPE, SEQUENCEOFTYPE, SEQUENCETYPE, SETOFTYPE, SETTYPE, SIGNEDNUMBER, SIZECONSTRAINT, SKIPTOEND, SNMPACCESSPART, SNMPAGENTCAPABILITIESMACROTYPE, SNMPCOMPLIANCEPART, SNMPCONTACTPART, SNMPCREATIONPART, SNMPDEFVALPART, SNMPDESCRPART, SNMPDISPLAYPART, SNMPENTERPRISEPART, SNMPINDEXPART, SNMPMANDATORYPART, SNMPMODULECOMPLIANCEMACROTYPE, SNMPMODULEIDENTITYMACROTYPE, SNMPMODULEPART, SNMPMODULESUPPORTPART, SNMPNOTIFICATIONGROUPMACROTYPE, SNMPNOTIFICATIONSPART, SNMPNOTIFICATIONTYPEMACROTYPE, SNMPOBJECTGROUPMACROTYPE, SNMPOBJECTIDENTITYMACROTYPE, SNMPOBJECTSPART, SNMPOBJECTTYPEMACROTYPE, SNMPORGANIZATIONPART, SNMPPRODUCTRELEASEPART, SNMPREFERPART, SNMPREVISIONPART, SNMPSTATUSPART, SNMPSYNTAXPART, SNMPTEXTUALCONVENTIONMACROTYPE, SNMPTRAPTYPEMACROTYPE, SNMPUNITSPART, SNMPUPDATEPART, SNMPVARIATIONPART, SNMPVARPART, SNMPWRITESYNTAXPART, SPECIALREALVALUE, START, STRINGTYPE, SYMBOL, SYMBOLLIST, SYMBOLSFROMMODULE, SYMBOLSFROMMODULELIST, TABSENT, TACCESS, TAG, TAGDEFAULT, TAGENT_CAPABILITIES, TAGGEDTYPE, TANY, TAPPLICATION, TASSIGN, TAUGMENTS, TBAR, TBEGIN, TBINSTRING, TBIT, TBITS, TBOOLEAN, TBY, TCHOICE, TCOMMA, TCOMPONENT, TCOMPONENTS, TCONTACT_INFO, TCREATION_REQUIRES, TCSTRING, TDEFAULT, TDEFINED, TDEFINITIONS, TDEFVAL, TDESCRIPTION, TDISPLAY_HINT, TDOT, TEND, TENTERPRISE, TENUMERATED, TEXPLICIT, TEXPORTS, TFALSE, TFROM, TGROUP, THEXSTRING, TIDENT, TIDENTIFIER, TIMPLICIT, TIMPLIED, TIMPORTS, TINCLUDES, TINDEX, TINTEGER, TLAST_UPDATED, TLEFTBRACE, TLEFTBRACKET, TLEFTPAREN, TLESSTHAN, TMACRO, TMANDATORY_GROUPS, TMAX, TMAX_ACCESS, TMIN, TMIN_ACCESS, TMINUS, TMINUS_INFINITY, TMODULE, TMODULE_COMPLIANCE, TMODULE_IDENTITY, TNOTIFICATION_GROUP, TNOTIFICATION_TYPE, TNOTIFICATIONS, TNULL, TNUMBER, TOBJECT, TOBJECT_GROUP, TOBJECT_IDENTITY, TOBJECT_TYPE, TOBJECTS, TOCTET, TOF, tokenNodeName, TOPTIONAL, TORGANIZATION, TPLUS_INFINITY, TPRESENT, TPRIVATE, TPRODUCT_RELEASE, TREAL, TREFERENCE, TREVISION, TRIGHTBRACE, TRIGHTBRACKET, TRIGHTPAREN, TSEMI_COLON, TSEQUENCE, TSET, TSIZE, TSTATUS, TSTRING, TSUPPORTS, TSYNTAX, TTAGS, TTEXTUAL_CONVENTION, TTRAP_TYPE, TTRUE, TUNITS, TUNIVERSAL, TVARIABLES, TVARIATION, TWITH, TWRITE_SYNTAX, TYPE, TYPEASSIGNMENT, TYPEORBITS, TYPEORVALUE, TYPEORVALUELIST, TYPEREFERENCE, UPPERENDPOINT, VALUE, VALUEASSIGNMENT, VALUECONSTRAINT, VALUELIST, VALUERANGE, VARTYPES
 
Constructor Summary
Node()
           
 
Method Summary
 void apply(Switch sw)
          Calls the relevant caseX 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 caseX 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, or 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, or 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 the node types are identical, or false otherwise

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