View Javadoc

1   /* Generated By:JJTree: Do not edit this line. SimpleNode.java */
2   package org.codehaus.aspectwerkz.annotation.expression.ast;
3   
4   public class SimpleNode implements Node {
5       protected Node parent;
6   
7       protected Node[] children;
8   
9       protected int id;
10  
11      protected AnnotationParser parser;
12  
13      public SimpleNode(int i) {
14          id = i;
15      }
16  
17      public SimpleNode(AnnotationParser p, int i) {
18          this(i);
19          parser = p;
20      }
21  
22      public void jjtOpen() {
23      }
24  
25      public void jjtClose() {
26      }
27  
28      public void jjtSetParent(Node n) {
29          parent = n;
30      }
31  
32      public Node jjtGetParent() {
33          return parent;
34      }
35  
36      public void jjtAddChild(Node n, int i) {
37          if (children == null) {
38              children = new Node[i + 1];
39          } else if (i >= children.length) {
40              Node[] c = new Node[i + 1];
41              System.arraycopy(children, 0, c, 0, children.length);
42              children = c;
43          }
44          children[i] = n;
45      }
46  
47      public Node jjtGetChild(int i) {
48          return children[i];
49      }
50  
51      public int jjtGetNumChildren() {
52          return (children == null) ? 0 : children.length;
53      }
54  
55      /***
56       * Accept the visitor. *
57       */
58      public Object jjtAccept(AnnotationParserVisitor visitor, Object data) {
59          return visitor.visit(this, data);
60      }
61  
62      /***
63       * Accept the visitor. *
64       */
65      public Object childrenAccept(AnnotationParserVisitor visitor, Object data) {
66          if (children != null) {
67              for (int i = 0; i < children.length; ++i) {
68                  children[i].jjtAccept(visitor, data);
69              }
70          }
71          return data;
72      }
73  
74      /*
75       * You can override these two methods in subclasses of SimpleNode to customize the way the node appears when the
76       * tree is dumped. If your output uses more than one line you should override toString(String), otherwise overriding
77       * toString() is probably all you need to do.
78       */
79      public String toString() {
80          return AnnotationParserTreeConstants.jjtNodeName[id];
81      }
82  
83      public String toString(String prefix) {
84          return prefix + toString();
85      }
86  
87      /*
88       * Override this method if you want to customize how the node dumps out its children.
89       */
90      public void dump(String prefix) {
91          System.out.println(toString(prefix));
92          if (children != null) {
93              for (int i = 0; i < children.length; ++i) {
94                  SimpleNode n = (SimpleNode) children[i];
95                  if (n != null) {
96                      n.dump(prefix + " ");
97                  }
98              }
99          }
100     }
101 }