KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xquark > extractor > algebra > DefaultSimpleVisitor


1 /*
2  * This file belongs to the XQuark distribution.
3  * Copyright (C) 2003 Universite de Versailles Saint-Quentin.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307.
18  * You can also get it at http://www.gnu.org/licenses/lgpl.html
19  *
20  * For more information on this software, see http://www.xquark.org.
21  */

22
23 package org.xquark.extractor.algebra;
24
25
26 import java.util.List JavaDoc;
27
28 import org.xquark.extractor.common.SqlWrapperException;
29 import org.xquark.extractor.xfunctions.AfCast;
30 import org.xquark.extractor.xfunctions.XFunction;
31 import org.xquark.extractor.xfunctions.XfCast;
32
33 /**
34  *
35  * This base implementation of {@link org.xquark.extractor.algebra.AlgebraVisitor}
36  * performs a recursive depth-first browsing of an algebra tree. Operands, items,
37  * expressions and arguments are browsed, but not parameters (for UnaryAlgebra)
38  * and predicates (for all kinds of joins).
39  */

40 public class DefaultSimpleVisitor extends DefaultAlgebraVisitor {
41
42     private static final String JavaDoc RCSRevision = "$Revision: 1.3 $";
43     private static final String JavaDoc RCSName = "$Name: $";
44
45
46     public DefaultSimpleVisitor() {
47     }
48
49     public void visit(BinaryOperator arg){
50         arg.getLeftOperand().accept(this);
51         arg.getRightOperand().accept(this);
52     }
53
54     public void visit(FunAggregate arg) throws SqlWrapperException {
55         arg.getOperand().accept(this);
56     }
57
58     public void visit(IfThenElse arg) throws SqlWrapperException {
59         arg.getIf().accept(this);
60         arg.getThen().accept(this);
61         arg.getElse().accept(this);
62     }
63
64     public void visit(Join arg) throws SqlWrapperException {
65         List JavaDoc list = arg.getOperandList();
66         Expression expr = null;
67         if (null != list) {
68             for (int i = 0; i < list.size(); i++) {
69                 expr = (Expression)list.get(i);
70                 expr.accept(this);
71             }
72         }
73     }
74
75     public void visit(SortSpecification arg) throws SqlWrapperException {
76         arg.getSortExpression().accept(this);
77     }
78
79     public void visit(TupleExpression arg) throws SqlWrapperException {
80         List JavaDoc list = arg.getItemList();
81         Expression expr = null;
82         if (null != list) {
83             for (int i = 0; i < list.size(); i++) {
84                 expr = (Expression)list.get(i);
85                 expr.accept(this);
86             }
87         }
88     }
89
90     public void visit(UnaryOperator arg) {
91         arg.getOperand().accept(this);
92     }
93
94     public void visit(AfCast arg) throws SqlWrapperException {
95         arg.getExpression().accept(this);
96     }
97
98     public void visit(XfCast arg) throws SqlWrapperException {
99         arg.getExpression().accept(this);
100     }
101
102     public void visit(XFunction arg)throws SqlWrapperException {
103         List JavaDoc list = arg.getArguments();
104         Expression expr = null;
105         if (null != list) {
106             for (int i = 0; i < list.size(); i++) {
107                 expr = (Expression)list.get(i);
108                 expr.accept(this);
109             }
110         }
111     }
112 }
113
Popular Tags