View Javadoc

1   /*
2    * Copyright 2004-2006 the Seasar Foundation and the Others.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
13   * either express or implied. See the License for the specific language
14   * governing permissions and limitations under the License.
15   */
16  /* Generated By:JJTree: Do not edit this line. SimpleNode.java */
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    /* You can override these two methods in subclasses of SimpleNode to
79       customize the way the node appears when the tree is dumped.  If
80       your output uses more than one line you should override
81       toString(String), otherwise overriding toString() is probably all
82       you need to do. */
83  
84    public String toString() { return WikiParserTreeConstants.jjtNodeName[id]; }
85    public String toString(String prefix) { return prefix + toString(); }
86  
87    /* Override this method if you want to customize how the node dumps
88       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 }
102