KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > aspectwerkz > expression > ast > SimpleNode


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4
5 /* Generated By:JJTree: Do not edit this line. SimpleNode.java */
6
7 package com.tc.aspectwerkz.expression.ast;
8
9 public class SimpleNode implements Node {
10   protected Node parent;
11
12   protected Node[] children;
13
14   protected int id;
15
16   protected ExpressionParser parser;
17
18   public SimpleNode(int i) {
19     id = i;
20   }
21
22   public SimpleNode(ExpressionParser p, int i) {
23     this(i);
24     parser = p;
25   }
26
27   public void jjtOpen() {
28   }
29
30   public void jjtClose() {
31   }
32
33   public void jjtSetParent(Node n) {
34     parent = n;
35   }
36
37   public Node jjtGetParent() {
38     return parent;
39   }
40
41   public void jjtAddChild(Node n, int i) {
42     if (children == null) {
43       children = new Node[i + 1];
44     } else if (i >= children.length) {
45       Node c[] = new Node[i + 1];
46       System.arraycopy(children, 0, c, 0, children.length);
47       children = c;
48     }
49     children[i] = n;
50   }
51
52   public Node jjtGetChild(int i) {
53     return children[i];
54   }
55
56   public int jjtGetNumChildren() {
57     return (children == null) ? 0 : children.length;
58   }
59
60   /**
61    * Accept the visitor. *
62    */

63   public Object JavaDoc jjtAccept(ExpressionParserVisitor visitor, Object JavaDoc data) {
64     return visitor.visit(this, data);
65   }
66
67   /**
68    * Accept the visitor. *
69    */

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

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

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