001/* Generated By:JJTree: Do not edit this line. SimpleNode.java Version 7.0 */ 002/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ 003package jmri.jmris.srcp.parser; 004 005public 006class SimpleNode implements Node { 007 008 protected Node parent; 009 protected Node[] children; 010 protected int id; 011 protected Object value; 012 protected SRCPParser parser; 013 014 public SimpleNode(int i) { 015 id = i; 016 } 017 018 public SimpleNode(SRCPParser p, int i) { 019 this(i); 020 parser = p; 021 } 022 023 public void jjtOpen() { 024 } 025 026 public void jjtClose() { 027 } 028 029 public void jjtSetParent(Node n) { parent = n; } 030 public Node jjtGetParent() { return parent; } 031 032 public void jjtAddChild(Node n, int i) { 033 if (children == null) { 034 children = new Node[i + 1]; 035 } else if (i >= children.length) { 036 Node c[] = new Node[i + 1]; 037 System.arraycopy(children, 0, c, 0, children.length); 038 children = c; 039 } 040 children[i] = n; 041 } 042 043 public Node jjtGetChild(int i) { 044 return children[i]; 045 } 046 047 public int jjtGetNumChildren() { 048 return (children == null) ? 0 : children.length; 049 } 050 051 public void jjtSetValue(Object value) { this.value = value; } 052 public Object jjtGetValue() { return value; } 053 054 /* Accept the visitor. **/ 055 public Object jjtAccept(SRCPParserVisitor visitor, Object data) 056{ 057 return visitor.visit(this, data); 058 } 059 060 /* Accept the visitor. **/ 061 public Object childrenAccept(SRCPParserVisitor visitor, Object data) 062{ 063 if (children != null) { 064 for (int i = 0; i < children.length; ++i) { 065 children[i].jjtAccept(visitor, data); 066 } 067 } 068 return data; 069 } 070 071 /* You can override these two methods in subclasses of SimpleNode to 072 customize the way the node appears when the tree is dumped. If 073 your output uses more than one line you should override 074 toString(String), otherwise overriding toString() is probably all 075 you need to do. */ 076 077 public String toString() { 078 return SRCPParserTreeConstants.jjtNodeName[id]; 079 } 080 public String toString(String prefix) { return prefix + toString(); } 081 082 /* Override this method if you want to customize how the node dumps 083 out its children. */ 084 085 public void dump(String prefix) { 086 System.out.println(toString(prefix)); 087 if (children != null) { 088 for (int i = 0; i < children.length; ++i) { 089 SimpleNode n = (SimpleNode)children[i]; 090 if (n != null) { 091 n.dump(prefix + " "); 092 } 093 } 094 } 095 } 096 097 public int getId() { 098 return id; 099 } 100} 101 102/* JavaCC - OriginalChecksum=820d6bc9877cc5e5be6993e30d504541 (do not edit this line) */