KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mckoi > database > interpret > ByColumn


1 /**
2  * com.mckoi.database.interpret.ByColumn 09 Sep 2001
3  *
4  * Mckoi SQL Database ( http://www.mckoi.com/database )
5  * Copyright (C) 2000, 2001, 2002 Diehl and Associates, Inc.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * Version 2 as published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License Version 2 for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * Version 2 along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19  *
20  * Change Log:
21  *
22  *
23  */

24
25 package com.mckoi.database.interpret;
26
27 import com.mckoi.database.*;
28
29 /**
30  * Object used to represent a column in the 'order by' and 'group by'
31  * clauses of a select statement.
32  *
33  * @author Tobias Downer
34  */

35
36 public final class ByColumn
37             implements java.io.Serializable JavaDoc, StatementTreeObject, Cloneable JavaDoc {
38
39   static final long serialVersionUID = 8194415767416200855L;
40
41   /**
42    * The name of the column in the 'by'.
43    */

44   public Variable name;
45
46   /**
47    * The expression that we are ordering by.
48    */

49   public Expression exp;
50
51   /**
52    * If 'order by' then true if sort is ascending (default).
53    */

54   public boolean ascending = true;
55
56
57   public void prepareExpressions(ExpressionPreparer preparer)
58                                                   throws DatabaseException {
59     if (exp != null) {
60       exp.prepare(preparer);
61     }
62   }
63
64   public Object JavaDoc clone() throws CloneNotSupportedException JavaDoc {
65     ByColumn v = (ByColumn) super.clone();
66     if (name != null) {
67       v.name = (Variable) name.clone();
68     }
69     if (exp != null) {
70       v.exp = (Expression) exp.clone();
71     }
72     return v;
73   }
74
75   public String JavaDoc toString() {
76     return "ByColumn(" + name + ", " + exp + ", " + ascending + ")";
77   }
78
79 }
80
Popular Tags