01: /*
02: * Copyright (C) 1999-2004 <a href="mailto:mandarax@jbdietrich.com">Jens Dietrich</a>
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */
18:
19: package org.mandarax.jdbc.server.sql;
20:
21: import java.util.*;
22:
23: /**
24: * Represents the SQL column list.
25: * @author <A HREF="mailto:mandarax@jbdietrich.com">Jens Dietrich</A>
26: * @version 3.3.2 <29 December 2004>
27: * @since 3.0
28: */
29:
30: public class SelectClauseColumnList extends SelectClause implements
31: ColumnTermContext {
32: private List columns = new ArrayList();
33:
34: /**
35: * Constructor.
36: */
37: public SelectClauseColumnList() {
38: super ();
39: }
40:
41: /**
42: * Add a column to the list.
43: * @param item a new column.
44: */
45: public void add(ColumnTerm col) {
46: columns.add(col);
47: }
48:
49: /**
50: * Get the columns as list.
51: * @return a list of columns.
52: */
53: public List getColumns() {
54: return columns;
55: }
56:
57: /**
58: * Compares objects.
59: * @param obj another object.
60: * @return a boolean
61: */
62: public boolean sameAs(Object obj) {
63: if (obj != null && obj instanceof SelectClauseColumnList) {
64: SelectClauseColumnList s = (SelectClauseColumnList) obj;
65: boolean result = true;
66: result = result && s.columns.equals(s.columns);
67: return result;
68: }
69: return false;
70: }
71:
72: /**
73: * Print the object on a buffer in order to display the parsed SQL.
74: * @param out a string bufer to print on
75: */
76: public void print(StringBuffer out) {
77: for (int i = 0; i < columns.size(); i++) {
78: if (i > 0)
79: out.append(',');
80: ((ColumnTerm) columns.get(i)).print(out);
81: }
82: }
83:
84: }
|