1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.seasar.tuigwaa.cms.core.wiki.engine;
19
20 public class SimpleNode implements Node {
21 protected Node parent;
22 protected Node[] children;
23 protected int id;
24 protected WikiParser parser;
25
26 public SimpleNode(int i) {
27 id = i;
28 }
29
30 public SimpleNode(WikiParser p, int i) {
31 this(i);
32 parser = p;
33 }
34
35 public void jjtOpen() {
36 }
37
38 public void jjtClose() {
39 }
40
41 public void jjtSetParent(Node n) { parent = n; }
42 public Node jjtGetParent() { return parent; }
43
44 public void jjtAddChild(Node n, int i) {
45 if (children == null) {
46 children = new Node[i + 1];
47 } else if (i >= children.length) {
48 Node c[] = new Node[i + 1];
49 System.arraycopy(children, 0, c, 0, children.length);
50 children = c;
51 }
52 children[i] = n;
53 }
54
55 public Node jjtGetChild(int i) {
56 return children[i];
57 }
58
59 public int jjtGetNumChildren() {
60 return (children == null) ? 0 : children.length;
61 }
62
63 /*** Accept the visitor. **/
64 public Object jjtAccept(WikiParserVisitor visitor, Object data) {
65 return visitor.visit(this, data);
66 }
67
68 /*** Accept the visitor. **/
69 public Object childrenAccept(WikiParserVisitor visitor, Object data) {
70 if (children != null) {
71 for (int i = 0; i < children.length; ++i) {
72 children[i].jjtAccept(visitor, data);
73 }
74 }
75 return data;
76 }
77
78
79
80
81
82
83
84 public String toString() { return WikiParserTreeConstants.jjtNodeName[id]; }
85 public String toString(String prefix) { return prefix + toString(); }
86
87
88
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 }
102