View Javadoc

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      /*** Accept the visitor. * */
57      public Object jjtAccept(ExpressionParserVisitor visitor, Object data) {
58          return visitor.visit(this, data);
59      }
60  
61      /*** Accept the visitor. * */
62      public Object childrenAccept(ExpressionParserVisitor visitor, Object data) {
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      /*
72       * You can override these two methods in subclasses of SimpleNode to customize the way the node appears when the
73       * tree is dumped. If your output uses more than one line you should override toString(String), otherwise overriding
74       * toString() is probably all you need to do.
75       */
76  
77      public String toString() {
78          return ExpressionParserTreeConstants.jjtNodeName[id];
79      }
80  
81      public String toString(String prefix) {
82          return prefix + toString();
83      }
84  
85      /*
86       * Override this method if you want to customize how the node dumps out its children.
87       */
88  
89      public void dump(String prefix) {
90          System.out.println(toString(prefix));
91          if (children != null) {
92              for (int i = 0; i < children.length; ++i) {
93                  SimpleNode n = (SimpleNode) children[i];
94                  if (n != null) {
95                      n.dump(prefix + " ");
96                  }
97              }
98          }
99      }
100 }
101