KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mckoi > database > GroupHelper


1 /**
2  * com.mckoi.database.GroupHelper 25 Jun 1999
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;
26
27 import com.mckoi.util.IntegerVector;
28 import java.util.ArrayList JavaDoc;
29 import java.io.IOException JavaDoc;
30
31 /**
32  * This is a static class that provides the functionality for seperating a
33  * table into distinct groups. This class is used in the
34  * 'Table.group(String[] columns)' method.
35  * <p>
36  * @author Tobias Downer
37  * @deprecated don't use this anymore
38  */

39
40 final class GroupHelper {
41
42 // /**
43
// * The sorted table we are grouping.
44
// */
45
// private Table table;
46
//
47
// /**
48
// * The table enumerator.
49
// */
50
// private RowEnumeration row_enum;
51
//
52
// /**
53
// * The index of the last column we are grouping on.
54
// */
55
// private int last_col_index;
56
//
57
// /**
58
// * The last row index.
59
// */
60
// private int last_row_index;
61
//
62
// /**
63
// * The columns we are grouping over.
64
// */
65
// private int[] columns;
66

67
68   /**
69    * Constructs the helper.
70    */

71   GroupHelper(Table table, String JavaDoc[] col_names) {
72
73     throw new Error JavaDoc("Not used anymore");
74
75 // // Optimisation, pre-resolve the columns into indices
76
// columns = new int[col_names.length];
77
// for (int i = 0; i < columns.length; ++i) {
78
// int ci = table.findFieldName(col_names[i]);
79
// if (ci == -1) {
80
// throw new Error("Unknown field name in group ( " +
81
// col_names[i] + " )");
82
// }
83
// columns[i] = ci;
84
// }
85
//
86
// // Sort the tables by the column groups.
87
// for (int i = col_names.length - 1; i >= 0; --i) {
88
//// table = table.orderByColumn(col_names[i]);
89
// table = table.orderByColumn(columns[i], true);
90
// }
91
// this.table = table;
92
//
93
// row_enum = table.rowEnumeration();
94
// if (row_enum.hasMoreRows()) {
95
// last_row_index = row_enum.nextRowIndex();
96
// }
97
// else {
98
// last_row_index = -1;
99
// }
100

101   }
102
103 // /**
104
// * Returns the next group in the table. Returns 'null' if there are no
105
// * more groups in the table.
106
// */
107
// public VirtualTable nextGroup() {
108
// if (last_row_index != -1) {
109
//
110
// IntegerVector new_list = new IntegerVector(8);
111
//
112
// int row_index = last_row_index;
113
// int top_row_index = row_index;
114
//
115
// boolean equal = true;
116
//
117
// do {
118
// new_list.addInt(row_index);
119
// if (!row_enum.hasMoreRows()) {
120
// break;
121
// }
122
// row_index = row_enum.nextRowIndex();
123
//
124
// equal = true;
125
// for (int i = 0; i < columns.length && equal; ++i) {
126
// TObject cell = table.getCellContents(columns[i], top_row_index);
127
// equal = equal &&
128
// table.compareCellTo(cell, columns[i], row_index) == Table.EQUAL;
129
// }
130
//
131
// } while (equal);
132
//
133
// if (!equal) {
134
// last_row_index = row_index;
135
// }
136
// else {
137
// last_row_index = -1;
138
// }
139
//
140
//
141
// VirtualTable vtable = new VirtualTable(table);
142
// vtable.set(table, new_list);
143
// return vtable;
144
//
145
// }
146
// else {
147
// return null;
148
// }
149
//
150
//
151
// }
152
//
153
//
154
//
155
// public static final VirtualTable[] group(Table table, String[] groups) {
156
//
157
//
158
// GroupHelper g_help = new GroupHelper(table, groups);
159
// ArrayList list = new ArrayList();
160
// VirtualTable tab = g_help.nextGroup();
161
// while (tab != null) {
162
// list.add(tab);
163
// tab = g_help.nextGroup();
164
// }
165
//
166
// // Make into an array
167
// VirtualTable[] table_array = (VirtualTable[])
168
// list.toArray(new VirtualTable[list.size()]);
169
// return table_array;
170
//
171
// }
172

173
174 }
175
Popular Tags