KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xquark > extractor > oracle > OracleGenSqlVisitor


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.oracle;
24
25 import org.xquark.extractor.algebra.BinOpArithmetic;
26 import org.xquark.extractor.algebra.DummyTable;
27 import org.xquark.extractor.algebra.Expression;
28 import org.xquark.extractor.runtime.IDProvider;
29 import org.xquark.extractor.sql.AbstractGenSqlVisitor;
30 import org.xquark.extractor.sql.SqlExpression;
31 import org.xquark.extractor.sql.SqlFactory;
32
33 public final class OracleGenSqlVisitor extends AbstractGenSqlVisitor {
34
35     private static final String JavaDoc RCSRevision = "$Revision: 1.9 $";
36     private static final String JavaDoc RCSName = "$Name: $";
37
38     public OracleGenSqlVisitor(IDProvider relIDProvider) {
39         super((SqlFactory) OracleFactory.getInstance(), relIDProvider);
40     }
41
42     public SqlExpression visit(BinOpArithmetic arg) {
43         //Trace.enter(this, "visit(BinOpArithmetic arg)");
44

45         SqlExpression retVal = null;
46
47         Expression aLOprnd = arg.getLeftOperand();
48         SqlExpression sLOprnd = aLOprnd.accept(this);
49
50         Expression aROprnd = arg.getRightOperand();
51         SqlExpression sROprnd = aROprnd.accept(this);
52
53         int oprtr = arg.getOperator();
54
55         retVal = _factory.createBinOpArithmetic(oprtr, sLOprnd, sROprnd);
56
57         if (false /** @todo INT_DIVIDE_ARITHMETICS == oprtr &&
58                     aLOprnd.getType().isInteger() &&
59                     aROprnd.getType().isInteger()*/

60             ) {
61             /** @todo pay attention that the round funcion on negative values */
62             retVal = _factory.createSfRound(retVal);
63         }
64
65         //Trace.exit(this, "visit(BinOpArithmetic arg)");
66
return retVal;
67     }
68
69     protected org.xquark.extractor.sql.SqlSelect selectAddFromClause(org.xquark.extractor.sql.SqlSelect select, DummyTable operand) {
70         //Trace.enter(this, "selectAddFromClause (SqlSelect select, DummyTable operand)");
71

72         org.xquark.extractor.sql.SqlTable newFrom = _factory.createTable("dual");
73         select.addFromClause(newFrom);
74
75         //Trace.exit(this, "selectAddFromClause (SqlSelect select, DummyTable operand)");
76
return select;
77     }
78 }
79
Popular Tags