KickJava   Java API By Example, From Geeks To Geeks.

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


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.ArrayList JavaDoc;
26 import java.util.List JavaDoc;
27
28 import org.xquark.extractor.common.Debug;
29 import org.xquark.extractor.common.SqlWrapperException;
30
31 /**
32  * Grabs top-level (blocks on 1st project encoutered) in a list.
33  * UNUSED
34  */

35 public final class TopLevelProjectsVisitor extends DefaultAlgebraVisitor {
36     private static final String JavaDoc RCSRevision = "$Revision: 1.6 $";
37     private static final String JavaDoc RCSName = "$Name: $";
38
39     private List JavaDoc _topLevelProjectList = new ArrayList JavaDoc();
40
41     public TopLevelProjectsVisitor() {
42     }
43
44     public void reinit() {
45         _topLevelProjectList.clear();
46     }
47
48     public List JavaDoc getProjectList(){
49         Debug.assertTrue(!_topLevelProjectList.isEmpty(),"!_topLevelProjectList.isEmpty()");
50         return _topLevelProjectList;
51     }
52
53     public void visit(Expression arg) throws SqlWrapperException {
54         Debug.assertTrue(false, "NYI for " + arg.pprint());
55     }
56
57     public void visit(BinaryAlgebra arg) throws SqlWrapperException {
58         //Trace.enter(this,"visit(BinaryAlgebra arg)", arg);
59
arg.getLeftOperand().accept(this);
60         arg.getRightOperand().accept(this);
61         //Trace.exit(this,"visit(BinaryAlgebra arg)", arg);
62
}
63
64     public void visit(Join arg) throws SqlWrapperException {
65         //Trace.enter(this,"visit(Join arg)", arg);
66

67         List JavaDoc list = arg.getOperands();
68         Debug.assertTrue(null!=list,"null!=list");
69
70         Expression expr = null ;
71         for (int i = 0; i < list.size(); i++) {
72             expr = (Expression)list.get(i);
73             expr.accept(this);
74         }
75
76         //Trace.exit(this,"visit(Join arg)", arg);
77
}
78
79     public void visit(UnaryAlgebra arg) throws SqlWrapperException {
80         //Trace.enter(this,"visit(UnaryAlgebra arg)", arg);
81

82         Expression operand = arg.getOperand();
83         operand.accept(this);
84
85         //Trace.exit(this,"visit(UnaryAlgebra arg)", arg);
86
}
87
88     public void visit(UnOpProject arg) throws SqlWrapperException {
89         //Trace.enter(this,"visit(UnOpProject arg)", arg);
90

91         _topLevelProjectList.add(arg);
92
93         //Trace.exit(this,"visit(UnOpProject arg)", arg);
94
}
95 }
96
Popular Tags