01 /* Generated By:JJTree: Do not edit this line. SimpleNode.java Version 4.3 */
02 /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=true,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=JSSP,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
03 package org.descripter.js.ss.parse;
04 
05 public
06 class SimpleNode implements Node {
07 
08   protected Node parent;
09   protected Node[] children;
10   protected int id;
11   protected Object value;
12   protected JSSPParser parser;
13 
14   public SimpleNode(int i) {
15     id = i;
16   }
17 
18   public SimpleNode(JSSPParser p, int i) {
19     this(i);
20     parser = p;
21   }
22 
23   public void jjtOpen() {
24   }
25 
26   public void jjtClose() {
27   }
28 
29   public void jjtSetParent(Node n) { parent = n; }
30   public Node jjtGetParent() { return parent; }
31 
32   public void jjtAddChild(Node n, int i) {
33     if (children == null) {
34       children = new Node[i + 1];
35     } else if (i >= children.length) {
36       Node c[] = new Node[i + 1];
37       System.arraycopy(children, 0, c, 0, children.length);
38       children = c;
39     }
40     children[i] = n;
41   }
42 
43   public Node jjtGetChild(int i) {
44     return children[i];
45   }
46 
47   public int jjtGetNumChildren() {
48     return (children == null) ? 0 : children.length;
49   }
50 
51   public void jjtSetValue(Object value) { this.value = value; }
52   public Object jjtGetValue() { return value; }
53 
54   /** Accept the visitor. **/
55   public Object jjtAccept(JSSPParserVisitor visitor, Object data)
56 {
57     return visitor.visit(this, data);
58   }
59 
60   /** Accept the visitor. **/
61   public Object childrenAccept(JSSPParserVisitor visitor, Object data)
62 {
63     if (children != null) {
64       for (int i = 0; i < children.length; ++i) {
65         children[i].jjtAccept(visitor, data);
66       }
67     }
68     return data;
69   }
70 
71   /* You can override these two methods in subclasses of SimpleNode to
72      customize the way the node appears when the tree is dumped.  If
73      your output uses more than one line you should override
74      toString(String), otherwise overriding toString() is probably all
75      you need to do. */
76 
77   public String toString() { return JSSPParserTreeConstants.jjtNodeName[id]; }
78   public String toString(String prefix) { return prefix + toString(); }
79 
80   /* Override this method if you want to customize how the node dumps
81      out its children. */
82 
83   public void dump(String prefix) {
84     System.out.println(toString(prefix));
85     if (children != null) {
86       for (int i = 0; i < children.length; ++i) {
87         SimpleNode n = (SimpleNode)children[i];
88         if (n != null) {
89           n.dump(prefix + " ");
90         }
91       }
92     }
93   }
94 }