01: /**
02: * com.mckoi.database.interpret.ByColumn 09 Sep 2001
03: *
04: * Mckoi SQL Database ( http://www.mckoi.com/database )
05: * Copyright (C) 2000, 2001, 2002 Diehl and Associates, Inc.
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License
09: * 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: */package com.mckoi.database.interpret;
24:
25: import com.mckoi.database.*;
26:
27: /**
28: * Object used to represent a column in the 'order by' and 'group by'
29: * clauses of a select statement.
30: *
31: * @author Tobias Downer
32: */
33:
34: public final class ByColumn implements java.io.Serializable,
35: StatementTreeObject, Cloneable {
36:
37: static final long serialVersionUID = 8194415767416200855L;
38:
39: /**
40: * The name of the column in the 'by'.
41: */
42: public Variable name;
43:
44: /**
45: * The expression that we are ordering by.
46: */
47: public Expression exp;
48:
49: /**
50: * If 'order by' then true if sort is ascending (default).
51: */
52: public boolean ascending = true;
53:
54: public void prepareExpressions(ExpressionPreparer preparer)
55: throws DatabaseException {
56: if (exp != null) {
57: exp.prepare(preparer);
58: }
59: }
60:
61: public Object clone() throws CloneNotSupportedException {
62: ByColumn v = (ByColumn) super .clone();
63: if (name != null) {
64: v.name = (Variable) name.clone();
65: }
66: if (exp != null) {
67: v.exp = (Expression) exp.clone();
68: }
69: return v;
70: }
71:
72: public String toString() {
73: return "ByColumn(" + name + ", " + exp + ", " + ascending + ")";
74: }
75:
76: }
|