KickJava   Java API By Example, From Geeks To Geeks.

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


1 /**
2  * com.mckoi.database.interpret.SelectColumn 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  * Represents a column selected to be in the output of a select statement.
31  * This includes being either an aggregate function, a column or "*" which
32  * is the entire set of columns.
33  *
34  * @author Tobias Downer
35  */

36
37 public final class SelectColumn
38             implements java.io.Serializable JavaDoc, StatementTreeObject, Cloneable JavaDoc {
39
40   static final long serialVersionUID = 2507375247510606004L;
41
42   /**
43    * If the column represents a glob of columns (eg. 'Part.*' or '*') then
44    * this is set to the glob string and 'expression' is left blank.
45    */

46   public String JavaDoc glob_name;
47
48   /**
49    * The fully resolved name that this column is given in the resulting table.
50    */

51   public Variable resolved_name;
52
53   /**
54    * The alias of this column string.
55    */

56   public String JavaDoc alias;
57
58   /**
59    * The expression of this column. This is only NOT set when name == "*"
60    * indicating all the columns.
61    */

62   public Expression expression;
63
64   /**
65    * The name of this column used internally to reference it.
66    */

67   public Variable internal_name;
68
69
70
71 // /**
72
// * Makes a deep clone of this object.
73
// */
74
// SelectColumn deepClone() {
75
// SelectColumn sc = new SelectColumn();
76
// sc.glob_name = glob_name;
77
// sc.resolved_name = resolved_name;
78
// sc.alias = alias;
79
// sc.expression = new Expression(expression);
80
// sc.internal_name = internal_name;
81
// return sc;
82
// }
83

84
85   // Implemented from StatementTreeObject
86
public void prepareExpressions(ExpressionPreparer preparer)
87                                                   throws DatabaseException {
88     if (expression != null) {
89       expression.prepare(preparer);
90     }
91   }
92
93   public Object JavaDoc clone() throws CloneNotSupportedException JavaDoc {
94     SelectColumn v = (SelectColumn) super.clone();
95     if (resolved_name != null) {
96       v.resolved_name = (Variable) resolved_name.clone();
97     }
98     if (expression != null) {
99       v.expression = (Expression) expression.clone();
100     }
101     if (internal_name != null) {
102       v.internal_name = (Variable) internal_name.clone();
103     }
104     return v;
105   }
106
107
108
109   public String JavaDoc toString() {
110     String JavaDoc str = "";
111     if (glob_name != null) str += " GLOB_NAME = " + glob_name;
112     if (resolved_name != null) str += " RESOLVED_NAME = " + resolved_name;
113     if (alias != null) str += " ALIAS = " + alias;
114     if (expression != null) str += " EXPRESSION = " + expression;
115     if (internal_name != null) str += " INTERNAL_NAME = " + internal_name;
116     return str;
117   }
118
119 }
120
Popular Tags