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=true,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
003package jmri.jmrix.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 SRCPClientParser parser;
013  protected Token firstToken;
014  protected Token lastToken;
015
016  public SimpleNode(int i) {
017    id = i;
018  }
019
020  public SimpleNode(SRCPClientParser p, int i) {
021    this(i);
022    parser = p;
023  }
024
025  public void jjtOpen() {
026  }
027
028  public void jjtClose() {
029  }
030
031  public void jjtSetParent(Node n) { parent = n; }
032  public Node jjtGetParent() { return parent; }
033
034  public void jjtAddChild(Node n, int i) {
035    if (children == null) {
036      children = new Node[i + 1];
037    } else if (i >= children.length) {
038      Node c[] = new Node[i + 1];
039      System.arraycopy(children, 0, c, 0, children.length);
040      children = c;
041    }
042    children[i] = n;
043  }
044
045  public Node jjtGetChild(int i) {
046    return children[i];
047  }
048
049  public int jjtGetNumChildren() {
050    return (children == null) ? 0 : children.length;
051  }
052
053  public void jjtSetValue(Object value) { this.value = value; }
054  public Object jjtGetValue() { return value; }
055
056  public Token jjtGetFirstToken() { return firstToken; }
057  public void jjtSetFirstToken(Token token) { this.firstToken = token; }
058  public Token jjtGetLastToken() { return lastToken; }
059  public void jjtSetLastToken(Token token) { this.lastToken = token; }
060
061  /* Accept the visitor. **/
062  public Object jjtAccept(SRCPClientParserVisitor visitor, Object data)
063{
064    return visitor.visit(this, data);
065  }
066
067  /* Accept the visitor. **/
068  public Object childrenAccept(SRCPClientParserVisitor visitor, Object data)
069{
070    if (children != null) {
071      for (int i = 0; i < children.length; ++i) {
072        children[i].jjtAccept(visitor, data);
073      }
074    }
075    return data;
076  }
077
078  /* You can override these two methods in subclasses of SimpleNode to
079     customize the way the node appears when the tree is dumped.  If
080     your output uses more than one line you should override
081     toString(String), otherwise overriding toString() is probably all
082     you need to do. */
083
084  public String toString() {
085    return SRCPClientParserTreeConstants.jjtNodeName[id];
086  }
087  public String toString(String prefix) { return prefix + toString(); }
088
089  /* Override this method if you want to customize how the node dumps
090     out its children. */
091
092  public void dump(String prefix) {
093    System.out.println(toString(prefix));
094    if (children != null) {
095      for (int i = 0; i < children.length; ++i) {
096        SimpleNode n = (SimpleNode)children[i];
097        if (n != null) {
098          n.dump(prefix + " ");
099        }
100      }
101    }
102  }
103
104  public int getId() {
105    return id;
106  }
107}
108
109/* JavaCC - OriginalChecksum=5f69c2fcb5e079e6ddc4858bdc7d93f8 (do not edit this line) */