KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xquark > extractor > sql > SqlFunAggregate


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.sql;
24
25
26 public class SqlFunAggregate extends SqlUnaryOperator
27 {
28
29     private static final String JavaDoc RCSRevision = "$Revision: 1.4 $";
30     private static final String JavaDoc RCSName = "$Name: $";
31
32     private boolean _distinct;
33     private int _operator;
34
35     /**
36     @param operator
37     @param operand
38     @param distinct
39     @roseuid 3BD177EE03B2
40      */

41     public SqlFunAggregate(int operator, SqlExpression operand, boolean distinct)
42     {
43
44         super ( operand );
45         setDistinct (distinct );
46         setOperator (operator) ;
47     }
48
49     /**
50     @roseuid 3BD177EE0376
51      */

52     public SqlFunAggregate()
53     {
54
55     }
56
57     /**
58     @return boolean
59     @roseuid 3BD177EF0147
60      */

61     public boolean getDistinct()
62     {
63         return _distinct ;
64     }
65
66     /**
67     @param distinct
68     @roseuid 3BD177EF018D
69      */

70     public void setDistinct(boolean distinct)
71     {
72         _distinct = distinct ;
73     }
74
75     /**
76     @param operator
77     @roseuid 3BD177EF0237
78      */

79     public void setOperator(int operator)
80     {
81         _operator = operator ;
82     }
83
84     /**
85     @return int
86     @roseuid 3BD177EF02C3
87      */

88     public int getOperator()
89     {
90         return _operator ;
91     }
92
93     /**
94     @return String
95     @roseuid 3BD177EF02F5
96      */

97     public String JavaDoc toSql(Context context)
98     {
99         //Trace.enter(this,"toSql(Context context)");
100
//
101
StringBuffer JavaDoc retVal = new StringBuffer JavaDoc();
102
103         retVal.append( AGGREGATEOPS[_operator]);
104         retVal.append("(");
105         if ( _distinct )
106         {
107             retVal.append("DISTINCT ");
108         }
109         retVal.append(getOperand().toSql(context));
110         retVal.append(")");
111
112         //Trace.exit(this,"toSql(Context context)");
113
//
114
return retVal.toString() ;
115     }
116 }
117
Popular Tags