KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > aop > annotation > ast > SimpleNode


1 /* Generated By:JJTree: Do not edit this line. SimpleNode.java */
2
3 package org.jboss.aop.annotation.ast;
4
5 public class SimpleNode implements Node {
6   protected Node parent;
7   protected Node[] children;
8   protected int id;
9   protected AnnotationParser parser;
10
11   public SimpleNode(int i) {
12     id = i;
13   }
14
15   public SimpleNode(AnnotationParser p, int i) {
16     this(i);
17     parser = p;
18   }
19
20   public void jjtOpen() {
21   }
22
23   public void jjtClose() {
24   }
25   
26   public void jjtSetParent(Node n) { parent = n; }
27   public Node jjtGetParent() { return parent; }
28
29   public void jjtAddChild(Node n, int i) {
30     if (children == null) {
31       children = new Node[i + 1];
32     } else if (i >= children.length) {
33       Node c[] = new Node[i + 1];
34       System.arraycopy(children, 0, c, 0, children.length);
35       children = c;
36     }
37     children[i] = n;
38   }
39
40   public Node jjtGetChild(int i) {
41     return children[i];
42   }
43
44   public int jjtGetNumChildren() {
45     return (children == null) ? 0 : children.length;
46   }
47
48   /** Accept the visitor. **/
49   public Object JavaDoc jjtAccept(AnnotationParserVisitor visitor, Object JavaDoc data) {
50     return visitor.visit(this, data);
51   }
52
53   /** Accept the visitor. **/
54   public Object JavaDoc childrenAccept(AnnotationParserVisitor visitor, Object JavaDoc data) {
55     if (children != null) {
56       for (int i = 0; i < children.length; ++i) {
57         children[i].jjtAccept(visitor, data);
58       }
59     }
60     return data;
61   }
62
63   /* You can override these two methods in subclasses of SimpleNode to
64      customize the way the node appears when the tree is dumped. If
65      your output uses more than one line you should override
66      toString(String), otherwise overriding toString() is probably all
67      you need to do. */

68
69   public String JavaDoc toString() { return AnnotationParserTreeConstants.jjtNodeName[id]; }
70   public String JavaDoc toString(String JavaDoc prefix) { return prefix + toString(); }
71
72   /* Override this method if you want to customize how the node dumps
73      out its children. */

74
75   public void dump(String JavaDoc prefix) {
76     System.out.println(toString(prefix));
77     if (children != null) {
78       for (int i = 0; i < children.length; ++i) {
79     SimpleNode n = (SimpleNode)children[i];
80     if (n != null) {
81       n.dump(prefix + " ");
82     }
83       }
84     }
85   }
86 }
87
88
Popular Tags