1 | package org.apache.velocity.runtime.visitor; |
2 | |
3 | /* |
4 | * Copyright 2000-2001,2004 The Apache Software Foundation. |
5 | * |
6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
7 | * you may not use this file except in compliance with the License. |
8 | * You may obtain a copy of the License at |
9 | * |
10 | * http://www.apache.org/licenses/LICENSE-2.0 |
11 | * |
12 | * Unless required by applicable law or agreed to in writing, software |
13 | * distributed under the License is distributed on an "AS IS" BASIS, |
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15 | * See the License for the specific language governing permissions and |
16 | * limitations under the License. |
17 | */ |
18 | |
19 | import java.io.Writer; |
20 | |
21 | import org.apache.velocity.context.InternalContextAdapter; |
22 | |
23 | import org.apache.velocity.runtime.parser.node.*; |
24 | |
25 | /** |
26 | * This is the base class for all visitors. |
27 | * For each AST node, this class will provide |
28 | * a bare-bones method for traversal. |
29 | * |
30 | * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a> |
31 | * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a> |
32 | * @version $Id: BaseVisitor.java,v 1.12.4.1 2004/03/03 23:23:02 geirm Exp $ |
33 | */ |
34 | public abstract class BaseVisitor implements ParserVisitor |
35 | { |
36 | /** Context used during traversal */ |
37 | protected InternalContextAdapter context; |
38 | |
39 | /** Writer used as the output sink */ |
40 | protected Writer writer; |
41 | |
42 | public void setWriter( Writer writer ) |
43 | { |
44 | this.writer = writer; |
45 | } |
46 | |
47 | public void setContext( InternalContextAdapter context) |
48 | { |
49 | this.context = context; |
50 | } |
51 | |
52 | public Object visit(SimpleNode node, Object data) |
53 | { |
54 | data = node.childrenAccept(this, data); |
55 | return data; |
56 | } |
57 | |
58 | public Object visit(ASTprocess node, Object data) |
59 | { |
60 | data = node.childrenAccept(this, data); |
61 | return data; |
62 | } |
63 | |
64 | public Object visit(ASTExpression node, Object data) |
65 | { |
66 | data = node.childrenAccept(this, data); |
67 | return data; |
68 | } |
69 | |
70 | public Object visit(ASTAssignment node, Object data) |
71 | { |
72 | data = node.childrenAccept(this, data); |
73 | return data; |
74 | } |
75 | |
76 | public Object visit(ASTOrNode node, Object data) |
77 | { |
78 | data = node.childrenAccept(this, data); |
79 | return data; |
80 | } |
81 | |
82 | public Object visit(ASTAndNode node, Object data) |
83 | { |
84 | data = node.childrenAccept(this, data); |
85 | return data; |
86 | } |
87 | |
88 | public Object visit(ASTEQNode node, Object data) |
89 | { |
90 | data = node.childrenAccept(this, data); |
91 | return data; |
92 | } |
93 | |
94 | public Object visit(ASTNENode node, Object data) |
95 | { |
96 | data = node.childrenAccept(this, data); |
97 | return data; |
98 | } |
99 | |
100 | public Object visit(ASTLTNode node, Object data) |
101 | { |
102 | data = node.childrenAccept(this, data); |
103 | return data; |
104 | } |
105 | |
106 | public Object visit(ASTGTNode node, Object data) |
107 | { |
108 | data = node.childrenAccept(this, data); |
109 | return data; |
110 | } |
111 | |
112 | public Object visit(ASTLENode node, Object data) |
113 | { |
114 | data = node.childrenAccept(this, data); |
115 | return data; |
116 | } |
117 | |
118 | public Object visit(ASTGENode node, Object data) |
119 | { |
120 | data = node.childrenAccept(this, data); |
121 | return data; |
122 | } |
123 | |
124 | public Object visit(ASTAddNode node, Object data) |
125 | { |
126 | data = node.childrenAccept(this, data); |
127 | return data; |
128 | } |
129 | |
130 | public Object visit(ASTSubtractNode node, Object data) |
131 | { |
132 | data = node.childrenAccept(this, data); |
133 | return data; |
134 | } |
135 | |
136 | public Object visit(ASTMulNode node, Object data) |
137 | { |
138 | data = node.childrenAccept(this, data); |
139 | return data; |
140 | } |
141 | |
142 | public Object visit(ASTDivNode node, Object data) |
143 | { |
144 | data = node.childrenAccept(this, data); |
145 | return data; |
146 | } |
147 | |
148 | public Object visit(ASTModNode node, Object data) |
149 | { |
150 | data = node.childrenAccept(this, data); |
151 | return data; |
152 | } |
153 | |
154 | public Object visit(ASTNotNode node, Object data) |
155 | { |
156 | data = node.childrenAccept(this, data); |
157 | return data; |
158 | } |
159 | |
160 | public Object visit(ASTNumberLiteral node, Object data) |
161 | { |
162 | data = node.childrenAccept(this, data); |
163 | return data; |
164 | } |
165 | |
166 | public Object visit(ASTStringLiteral node, Object data) |
167 | { |
168 | data = node.childrenAccept(this, data); |
169 | return data; |
170 | } |
171 | |
172 | public Object visit(ASTIdentifier node, Object data) |
173 | { |
174 | data = node.childrenAccept(this, data); |
175 | return data; |
176 | } |
177 | |
178 | public Object visit(ASTMethod node, Object data) |
179 | { |
180 | data = node.childrenAccept(this, data); |
181 | return data; |
182 | } |
183 | |
184 | public Object visit(ASTReference node, Object data) |
185 | { |
186 | data = node.childrenAccept(this, data); |
187 | return data; |
188 | } |
189 | |
190 | public Object visit(ASTTrue node, Object data) |
191 | { |
192 | data = node.childrenAccept(this, data); |
193 | return data; |
194 | } |
195 | |
196 | public Object visit(ASTFalse node, Object data) |
197 | { |
198 | data = node.childrenAccept(this, data); |
199 | return data; |
200 | } |
201 | |
202 | public Object visit(ASTBlock node, Object data) |
203 | { |
204 | data = node.childrenAccept(this, data); |
205 | return data; |
206 | } |
207 | |
208 | public Object visit(ASTText node, Object data) |
209 | { |
210 | data = node.childrenAccept(this, data); |
211 | return data; |
212 | } |
213 | |
214 | public Object visit(ASTIfStatement node, Object data) |
215 | { |
216 | data = node.childrenAccept(this, data); |
217 | return data; |
218 | } |
219 | |
220 | public Object visit(ASTElseStatement node, Object data) |
221 | { |
222 | data = node.childrenAccept(this, data); |
223 | return data; |
224 | } |
225 | |
226 | public Object visit(ASTElseIfStatement node, Object data) |
227 | { |
228 | data = node.childrenAccept(this, data); |
229 | return data; |
230 | } |
231 | |
232 | public Object visit(ASTComment node, Object data) |
233 | { |
234 | data = node.childrenAccept(this, data); |
235 | return data; |
236 | } |
237 | |
238 | public Object visit(ASTObjectArray node, Object data) |
239 | { |
240 | data = node.childrenAccept(this, data); |
241 | return data; |
242 | } |
243 | |
244 | public Object visit(ASTWord node, Object data) |
245 | { |
246 | data = node.childrenAccept(this, data); |
247 | return data; |
248 | } |
249 | |
250 | public Object visit(ASTSetDirective node, Object data) |
251 | { |
252 | data = node.childrenAccept(this, data); |
253 | return data; |
254 | } |
255 | |
256 | public Object visit(ASTDirective node, Object data) |
257 | { |
258 | data = node.childrenAccept(this, data); |
259 | return data; |
260 | } |
261 | } |