KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > codehaus > aspectwerkz > expression > ast > SimpleNode


1 /* Generated By:JJTree: Do not edit this line. SimpleNode.java */
2
3 package org.codehaus.aspectwerkz.expression.ast;
4
5 public class SimpleNode implements Node {
6     protected Node parent;
7
8     protected Node[] children;
9
10     protected int id;
11
12     protected ExpressionParser parser;
13
14     public SimpleNode(int i) {
15         id = i;
16     }
17
18     public SimpleNode(ExpressionParser 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) {
30         parent = n;
31     }
32
33     public Node jjtGetParent() {
34         return parent;
35     }
36
37     public void jjtAddChild(Node n, int i) {
38         if (children == null) {
39             children = new Node[i + 1];
40         } else if (i >= children.length) {
41             Node c[] = new Node[i + 1];
42             System.arraycopy(children, 0, c, 0, children.length);
43             children = c;
44         }
45         children[i] = n;
46     }
47
48     public Node jjtGetChild(int i) {
49         return children[i];
50     }
51
52     public int jjtGetNumChildren() {
53         return (children == null) ? 0 : children.length;
54     }
55
56     /**
57      * Accept the visitor. *
58      */

59     public Object JavaDoc jjtAccept(ExpressionParserVisitor visitor, Object JavaDoc data) {
60         return visitor.visit(this, data);
61     }
62
63     /**
64      * Accept the visitor. *
65      */

66     public Object JavaDoc childrenAccept(ExpressionParserVisitor visitor, Object JavaDoc data) {
67         if (children != null) {
68             for (int i = 0; i < children.length; ++i) {
69                 children[i].jjtAccept(visitor, data);
70             }
71         }
72         return data;
73     }
74
75     /*
76      * You can override these two methods in subclasses of SimpleNode to customize the way the node appears when the
77      * tree is dumped. If your output uses more than one line you should override toString(String), otherwise overriding
78      * toString() is probably all you need to do.
79      */

80
81     public String JavaDoc toString() {
82         return ExpressionParserTreeConstants.jjtNodeName[id];
83     }
84
85     public String JavaDoc toString(String JavaDoc prefix) {
86         return prefix + toString();
87     }
88
89     /*
90      * Override this method if you want to customize how the node dumps out its children.
91      */

92
93     public void dump(String JavaDoc prefix) {
94         System.out.println(toString(prefix));
95         if (children != null) {
96             for (int i = 0; i < children.length; ++i) {
97                 SimpleNode n = (SimpleNode) children[i];
98                 if (n != null) {
99                     n.dump(prefix + " ");
100                 }
101             }
102         }
103     }
104 }
105
106
Popular Tags