KickJava   Java API By Example, From Geeks To Geeks.

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


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 import java.util.List JavaDoc;
26
27 import org.xquark.extractor.common.SqlWrapperException;
28 import org.xquark.extractor.xfunctions.AfCast;
29 import org.xquark.extractor.xfunctions.XFunction;
30 import org.xquark.extractor.xfunctions.XfCast;
31
32 /**
33  *
34  * This base implementation of {@link org.xquark.extractor.algebra.AlgebraVisitor}
35  * performs a recursive depth-first browsing of an algebra tree. Operands, items,
36  * predicates, expressions, parameters and arguments are browsed.
37  */

38 public class DefaultCompleteVisitor extends DefaultAlgebraVisitor{
39     private static final String JavaDoc RCSRevision = "$Revision: 1.3 $";
40     private static final String JavaDoc RCSName = "$Name: $";
41
42
43     public DefaultCompleteVisitor() {
44     }
45
46     public void visit(BinaryAtomicOp arg){
47         arg.getLeftOperand().accept(this);
48         arg.getRightOperand().accept(this);
49     }
50     public void visit(BinaryAlgebra arg) throws SqlWrapperException {
51         arg.getLeftOperand().accept(this);
52         arg.getRightOperand().accept(this);
53     }
54
55     public void visit(BinOpOuterJoin arg) throws SqlWrapperException {
56         arg.getLeftOperand().accept(this);
57         arg.getRightOperand().accept(this);
58
59         List JavaDoc list = arg.getPredicateList();
60         Expression expr = null;
61         if (null != list) {
62             for (int i = 0; i < list.size(); i++) {
63                 expr = (Expression)list.get(i);
64                 expr.accept(this);
65             }
66         }
67     }
68
69     public void visit(FunAggregate arg) throws SqlWrapperException {
70         arg.getOperand().accept(this);
71     }
72
73     public void visit(IfThenElse arg) throws SqlWrapperException {
74         arg.getIf().accept(this);
75         arg.getThen().accept(this);
76         arg.getElse().accept(this);
77     }
78
79     public void visit(Join arg) throws SqlWrapperException {
80         List JavaDoc list = arg.getOperandList();
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         list = arg.getPredicateList();
90         if (null != list) {
91             for (int i = 0; i < list.size(); i++) {
92                 expr = (Expression)list.get(i);
93                 expr.accept(this);
94             }
95         }
96     }
97
98     public void visit(SortSpecification arg) throws SqlWrapperException {
99         arg.getSortExpression().accept(this);
100     }
101
102     public void visit(TupleExpression arg) throws SqlWrapperException {
103         List JavaDoc list = arg.getItemList();
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     public void visit(UnaryAlgebra arg) {
114         arg.getOperand().accept(this);
115
116         List JavaDoc list = arg.getParameterList();
117         Expression expr = null;
118         if (null != list) {
119             for (int i = 0; i < list.size(); i++) {
120                 expr = (Expression)list.get(i);
121                 expr.accept(this);
122             }
123         }
124     }
125
126     public void visit(UnaryAtomicOp arg) {
127         arg.getOperand().accept(this);
128     }
129
130     public void visit(AfCast arg) throws SqlWrapperException {
131         arg.getExpression().accept(this);
132     }
133
134     public void visit(XfCast arg) throws SqlWrapperException {
135         arg.getExpression().accept(this);
136     }
137
138     public void visit(XFunction arg)throws SqlWrapperException {
139         List JavaDoc list = arg.getArguments();
140         Expression expr = null;
141         if (null != list) {
142             for (int i = 0; i < list.size(); i++) {
143                 expr = (Expression)list.get(i);
144                 expr.accept(this);
145             }
146         }
147     }
148 }
149
Popular Tags