001: package org.apache.velocity.runtime.visitor;
002:
003: /*
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021:
022: import java.io.Writer;
023:
024: import org.apache.velocity.context.InternalContextAdapter;
025: import org.apache.velocity.runtime.parser.ParserVisitor;
026: import org.apache.velocity.runtime.parser.node.ASTAddNode;
027: import org.apache.velocity.runtime.parser.node.ASTAndNode;
028: import org.apache.velocity.runtime.parser.node.ASTAssignment;
029: import org.apache.velocity.runtime.parser.node.ASTBlock;
030: import org.apache.velocity.runtime.parser.node.ASTComment;
031: import org.apache.velocity.runtime.parser.node.ASTDirective;
032: import org.apache.velocity.runtime.parser.node.ASTDivNode;
033: import org.apache.velocity.runtime.parser.node.ASTEQNode;
034: import org.apache.velocity.runtime.parser.node.ASTElseIfStatement;
035: import org.apache.velocity.runtime.parser.node.ASTElseStatement;
036: import org.apache.velocity.runtime.parser.node.ASTEscape;
037: import org.apache.velocity.runtime.parser.node.ASTEscapedDirective;
038: import org.apache.velocity.runtime.parser.node.ASTExpression;
039: import org.apache.velocity.runtime.parser.node.ASTFalse;
040: import org.apache.velocity.runtime.parser.node.ASTFloatingPointLiteral;
041: import org.apache.velocity.runtime.parser.node.ASTGENode;
042: import org.apache.velocity.runtime.parser.node.ASTGTNode;
043: import org.apache.velocity.runtime.parser.node.ASTIdentifier;
044: import org.apache.velocity.runtime.parser.node.ASTIfStatement;
045: import org.apache.velocity.runtime.parser.node.ASTIntegerLiteral;
046: import org.apache.velocity.runtime.parser.node.ASTIntegerRange;
047: import org.apache.velocity.runtime.parser.node.ASTLENode;
048: import org.apache.velocity.runtime.parser.node.ASTLTNode;
049: import org.apache.velocity.runtime.parser.node.ASTMap;
050: import org.apache.velocity.runtime.parser.node.ASTMethod;
051: import org.apache.velocity.runtime.parser.node.ASTModNode;
052: import org.apache.velocity.runtime.parser.node.ASTMulNode;
053: import org.apache.velocity.runtime.parser.node.ASTNENode;
054: import org.apache.velocity.runtime.parser.node.ASTNotNode;
055: import org.apache.velocity.runtime.parser.node.ASTObjectArray;
056: import org.apache.velocity.runtime.parser.node.ASTOrNode;
057: import org.apache.velocity.runtime.parser.node.ASTReference;
058: import org.apache.velocity.runtime.parser.node.ASTSetDirective;
059: import org.apache.velocity.runtime.parser.node.ASTStop;
060: import org.apache.velocity.runtime.parser.node.ASTStringLiteral;
061: import org.apache.velocity.runtime.parser.node.ASTSubtractNode;
062: import org.apache.velocity.runtime.parser.node.ASTText;
063: import org.apache.velocity.runtime.parser.node.ASTTrue;
064: import org.apache.velocity.runtime.parser.node.ASTWord;
065: import org.apache.velocity.runtime.parser.node.ASTprocess;
066: import org.apache.velocity.runtime.parser.node.SimpleNode;
067:
068: /**
069: * This is the base class for all visitors.
070: * For each AST node, this class will provide
071: * a bare-bones method for traversal.
072: *
073: * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
074: * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
075: * @version $Id: BaseVisitor.java 463298 2006-10-12 16:10:32Z henning $
076: */
077: public abstract class BaseVisitor implements ParserVisitor {
078: /** Context used during traversal */
079: protected InternalContextAdapter context;
080:
081: /** Writer used as the output sink */
082: protected Writer writer;
083:
084: /**
085: * @param writer
086: */
087: public void setWriter(Writer writer) {
088: this .writer = writer;
089: }
090:
091: /**
092: * @param context
093: */
094: public void setContext(InternalContextAdapter context) {
095: this .context = context;
096: }
097:
098: /**
099: * @see org.apache.velocity.runtime.parser.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.SimpleNode, java.lang.Object)
100: */
101: public Object visit(SimpleNode node, Object data) {
102: data = node.childrenAccept(this , data);
103: return data;
104: }
105:
106: /**
107: * @see org.apache.velocity.runtime.parser.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTprocess, java.lang.Object)
108: */
109: public Object visit(ASTprocess node, Object data) {
110: data = node.childrenAccept(this , data);
111: return data;
112: }
113:
114: /**
115: * @see org.apache.velocity.runtime.parser.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTExpression, java.lang.Object)
116: */
117: public Object visit(ASTExpression node, Object data) {
118: data = node.childrenAccept(this , data);
119: return data;
120: }
121:
122: /**
123: * @see org.apache.velocity.runtime.parser.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTAssignment, java.lang.Object)
124: */
125: public Object visit(ASTAssignment node, Object data) {
126: data = node.childrenAccept(this , data);
127: return data;
128: }
129:
130: /**
131: * @see org.apache.velocity.runtime.parser.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTOrNode, java.lang.Object)
132: */
133: public Object visit(ASTOrNode node, Object data) {
134: data = node.childrenAccept(this , data);
135: return data;
136: }
137:
138: /**
139: * @see org.apache.velocity.runtime.parser.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTAndNode, java.lang.Object)
140: */
141: public Object visit(ASTAndNode node, Object data) {
142: data = node.childrenAccept(this , data);
143: return data;
144: }
145:
146: /**
147: * @see org.apache.velocity.runtime.parser.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTEQNode, java.lang.Object)
148: */
149: public Object visit(ASTEQNode node, Object data) {
150: data = node.childrenAccept(this , data);
151: return data;
152: }
153:
154: /**
155: * @see org.apache.velocity.runtime.parser.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTNENode, java.lang.Object)
156: */
157: public Object visit(ASTNENode node, Object data) {
158: data = node.childrenAccept(this , data);
159: return data;
160: }
161:
162: /**
163: * @see org.apache.velocity.runtime.parser.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTLTNode, java.lang.Object)
164: */
165: public Object visit(ASTLTNode node, Object data) {
166: data = node.childrenAccept(this , data);
167: return data;
168: }
169:
170: /**
171: * @see org.apache.velocity.runtime.parser.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTGTNode, java.lang.Object)
172: */
173: public Object visit(ASTGTNode node, Object data) {
174: data = node.childrenAccept(this , data);
175: return data;
176: }
177:
178: /**
179: * @see org.apache.velocity.runtime.parser.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTLENode, java.lang.Object)
180: */
181: public Object visit(ASTLENode node, Object data) {
182: data = node.childrenAccept(this , data);
183: return data;
184: }
185:
186: /**
187: * @see org.apache.velocity.runtime.parser.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTGENode, java.lang.Object)
188: */
189: public Object visit(ASTGENode node, Object data) {
190: data = node.childrenAccept(this , data);
191: return data;
192: }
193:
194: /**
195: * @see org.apache.velocity.runtime.parser.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTAddNode, java.lang.Object)
196: */
197: public Object visit(ASTAddNode node, Object data) {
198: data = node.childrenAccept(this , data);
199: return data;
200: }
201:
202: /**
203: * @see org.apache.velocity.runtime.parser.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTSubtractNode, java.lang.Object)
204: */
205: public Object visit(ASTSubtractNode node, Object data) {
206: data = node.childrenAccept(this , data);
207: return data;
208: }
209:
210: /**
211: * @see org.apache.velocity.runtime.parser.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTMulNode, java.lang.Object)
212: */
213: public Object visit(ASTMulNode node, Object data) {
214: data = node.childrenAccept(this , data);
215: return data;
216: }
217:
218: /**
219: * @see org.apache.velocity.runtime.parser.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTDivNode, java.lang.Object)
220: */
221: public Object visit(ASTDivNode node, Object data) {
222: data = node.childrenAccept(this , data);
223: return data;
224: }
225:
226: /**
227: * @see org.apache.velocity.runtime.parser.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTModNode, java.lang.Object)
228: */
229: public Object visit(ASTModNode node, Object data) {
230: data = node.childrenAccept(this , data);
231: return data;
232: }
233:
234: /**
235: * @see org.apache.velocity.runtime.parser.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTNotNode, java.lang.Object)
236: */
237: public Object visit(ASTNotNode node, Object data) {
238: data = node.childrenAccept(this , data);
239: return data;
240: }
241:
242: /**
243: * @see org.apache.velocity.runtime.parser.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTIntegerLiteral, java.lang.Object)
244: */
245: public Object visit(ASTIntegerLiteral node, Object data) {
246: data = node.childrenAccept(this , data);
247: return data;
248: }
249:
250: /**
251: * @see org.apache.velocity.runtime.parser.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTFloatingPointLiteral, java.lang.Object)
252: */
253: public Object visit(ASTFloatingPointLiteral node, Object data) {
254: data = node.childrenAccept(this , data);
255: return data;
256: }
257:
258: /**
259: * @see org.apache.velocity.runtime.parser.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTStringLiteral, java.lang.Object)
260: */
261: public Object visit(ASTStringLiteral node, Object data) {
262: data = node.childrenAccept(this , data);
263: return data;
264: }
265:
266: /**
267: * @see org.apache.velocity.runtime.parser.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTIdentifier, java.lang.Object)
268: */
269: public Object visit(ASTIdentifier node, Object data) {
270: data = node.childrenAccept(this , data);
271: return data;
272: }
273:
274: /**
275: * @see org.apache.velocity.runtime.parser.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTMethod, java.lang.Object)
276: */
277: public Object visit(ASTMethod node, Object data) {
278: data = node.childrenAccept(this , data);
279: return data;
280: }
281:
282: /**
283: * @see org.apache.velocity.runtime.parser.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTReference, java.lang.Object)
284: */
285: public Object visit(ASTReference node, Object data) {
286: data = node.childrenAccept(this , data);
287: return data;
288: }
289:
290: /**
291: * @see org.apache.velocity.runtime.parser.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTTrue, java.lang.Object)
292: */
293: public Object visit(ASTTrue node, Object data) {
294: data = node.childrenAccept(this , data);
295: return data;
296: }
297:
298: /**
299: * @see org.apache.velocity.runtime.parser.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTFalse, java.lang.Object)
300: */
301: public Object visit(ASTFalse node, Object data) {
302: data = node.childrenAccept(this , data);
303: return data;
304: }
305:
306: /**
307: * @see org.apache.velocity.runtime.parser.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTBlock, java.lang.Object)
308: */
309: public Object visit(ASTBlock node, Object data) {
310: data = node.childrenAccept(this , data);
311: return data;
312: }
313:
314: /**
315: * @see org.apache.velocity.runtime.parser.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTText, java.lang.Object)
316: */
317: public Object visit(ASTText node, Object data) {
318: data = node.childrenAccept(this , data);
319: return data;
320: }
321:
322: /**
323: * @see org.apache.velocity.runtime.parser.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTIfStatement, java.lang.Object)
324: */
325: public Object visit(ASTIfStatement node, Object data) {
326: data = node.childrenAccept(this , data);
327: return data;
328: }
329:
330: /**
331: * @see org.apache.velocity.runtime.parser.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTElseStatement, java.lang.Object)
332: */
333: public Object visit(ASTElseStatement node, Object data) {
334: data = node.childrenAccept(this , data);
335: return data;
336: }
337:
338: /**
339: * @see org.apache.velocity.runtime.parser.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTElseIfStatement, java.lang.Object)
340: */
341: public Object visit(ASTElseIfStatement node, Object data) {
342: data = node.childrenAccept(this , data);
343: return data;
344: }
345:
346: /**
347: * @see org.apache.velocity.runtime.parser.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTComment, java.lang.Object)
348: */
349: public Object visit(ASTComment node, Object data) {
350: data = node.childrenAccept(this , data);
351: return data;
352: }
353:
354: /**
355: * @see org.apache.velocity.runtime.parser.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTObjectArray, java.lang.Object)
356: */
357: public Object visit(ASTObjectArray node, Object data) {
358: data = node.childrenAccept(this , data);
359: return data;
360: }
361:
362: /**
363: * @see org.apache.velocity.runtime.parser.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTWord, java.lang.Object)
364: */
365: public Object visit(ASTWord node, Object data) {
366: data = node.childrenAccept(this , data);
367: return data;
368: }
369:
370: /**
371: * @see org.apache.velocity.runtime.parser.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTSetDirective, java.lang.Object)
372: */
373: public Object visit(ASTSetDirective node, Object data) {
374: data = node.childrenAccept(this , data);
375: return data;
376: }
377:
378: /**
379: * @see org.apache.velocity.runtime.parser.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTDirective, java.lang.Object)
380: */
381: public Object visit(ASTDirective node, Object data) {
382: data = node.childrenAccept(this , data);
383: return data;
384: }
385:
386: /**
387: * @see org.apache.velocity.runtime.parser.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTEscapedDirective, java.lang.Object)
388: */
389: public Object visit(ASTEscapedDirective node, Object data) {
390: data = node.childrenAccept(this , data);
391: return data;
392: }
393:
394: /**
395: * @see org.apache.velocity.runtime.parser.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTEscape, java.lang.Object)
396: */
397: public Object visit(ASTEscape node, Object data) {
398: data = node.childrenAccept(this , data);
399: return data;
400: }
401:
402: /**
403: * @see org.apache.velocity.runtime.parser.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTMap, java.lang.Object)
404: */
405: public Object visit(ASTMap node, Object data) {
406: data = node.childrenAccept(this , data);
407: return data;
408: }
409:
410: /**
411: * @see org.apache.velocity.runtime.parser.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTIntegerRange, java.lang.Object)
412: */
413: public Object visit(ASTIntegerRange node, Object data) {
414: data = node.childrenAccept(this , data);
415: return data;
416: }
417:
418: /**
419: * @see org.apache.velocity.runtime.parser.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTStop, java.lang.Object)
420: */
421: public Object visit(ASTStop node, Object data) {
422: data = node.childrenAccept(this, data);
423: return data;
424: }
425: }
|