Source code: com/rohanclan/ashpool/core/AResultSetMetaData.java
1 /*
2 * Ashpool - XML Database
3 * Copyright (C) 2003 Rob Rohan
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 675 Mass Ave, Cambridge, MA 02139, USA.
17 *
18 * AResultSetMetaData.java
19 *
20 * Created on February 2, 2003, 5:49 AM
21 */
22
23 package com.rohanclan.ashpool.core;
24
25 import java.sql.*;
26 import com.rohanclan.ashpool.core.*;
27
28 /**
29 * Metadata object for a AResultSet
30 * @author Rob Rohan
31 */
32 public class AResultSetMetaData implements java.sql.ResultSetMetaData {
33
34 private AResultSet rs;
35
36 /** Creates a new instance of AResultSetMetaData */
37 public AResultSetMetaData() {;}
38
39 public AResultSetMetaData(AResultSet prs){
40 this.rs = prs;
41 }
42
43 /** Gets the designated column's table's catalog name.
44 *
45 * @param column the first column is 1, the second is 2, ...
46 * @return the name of the catalog for the table in which the given column
47 * appears or "" if not applicable
48 * @exception SQLException if a database access error occurs
49 *
50 */
51 public String getCatalogName(int column) throws SQLException {
52 return "";
53 }
54
55 /** <p>Returns the fully-qualified name of the Java class whose instances
56 * are manufactured if the method <code>ResultSet.getObject</code>
57 * is called to retrieve a value
58 * from the column. <code>ResultSet.getObject</code> may return a subclass of the
59 * class returned by this method.
60 *
61 * @param column the first column is 1, the second is 2, ...
62 * @return the fully-qualified name of the class in the Java programming
63 * language that would be used by the method
64 * <code>ResultSet.getObject</code> to retrieve the value in the specified
65 * column. This is the class name used for custom mapping.
66 * @exception SQLException if a database access error occurs
67 * @since 1.2
68 *
69 */
70 public String getColumnClassName(int column) throws SQLException {
71 return "";
72 }
73
74 /** Returns the number of columns in this <code>ResultSet</code> object.
75 *
76 * @return the number of columns
77 * @exception SQLException if a database access error occurs
78 *
79 */
80 public int getColumnCount() throws SQLException {
81 return rs.getResultTable().size();
82 }
83
84 public int getRecordCount() throws SQLException {
85 //they should all be the same
86 return ((ResultColumn)rs.getResultTable().get(0)).columnData.size();
87 }
88
89 /** Indicates the designated column's normal maximum width in characters.
90 *
91 * @param column the first column is 1, the second is 2, ...
92 * @return the normal maximum number of characters allowed as the width
93 * of the designated column
94 * @exception SQLException if a database access error occurs
95 *
96 */
97 public int getColumnDisplaySize(int column) throws SQLException {
98 return 20;
99 }
100
101 /** Gets the designated column's suggested title for use in printouts and
102 * displays.
103 *
104 * @param column the first column is 1, the second is 2, ...
105 * @return the suggested column title
106 * @exception SQLException if a database access error occurs
107 *
108 */
109 public String getColumnLabel(int column) throws SQLException {
110 return ((ResultColumn)rs.getResultTable().get(column-1)).columnName;
111 }
112
113 /** Get the designated column's name.
114 *
115 * @param column the first column is 1, the second is 2, ...
116 * @return column name
117 * @exception SQLException if a database access error occurs
118 *
119 */
120 public String getColumnName(int column) throws SQLException {
121 return ((ResultColumn)rs.getResultTable().get(column-1)).columnName;
122 }
123
124 /** Retrieves the designated column's SQL type.
125 *
126 * @param column the first column is 1, the second is 2, ...
127 * @return SQL type from java.sql.Types
128 * @exception SQLException if a database access error occurs
129 * @see Types
130 *
131 */
132 public int getColumnType(int column) throws SQLException {
133 return ((ResultColumn)rs.getResultTable().get(column-1)).type;
134 }
135
136 /** Retrieves the designated column's database-specific type name.
137 *
138 * @param column the first column is 1, the second is 2, ...
139 * @return type name used by the database. If the column type is
140 * a user-defined type, then a fully-qualified type name is returned.
141 * @exception SQLException if a database access error occurs
142 *
143 */
144 public String getColumnTypeName(int column) throws SQLException {
145 return "undefined";
146 }
147
148 /** Get the designated column's number of decimal digits.
149 *
150 * @param column the first column is 1, the second is 2, ...
151 * @return precision
152 * @exception SQLException if a database access error occurs
153 *
154 */
155 public int getPrecision(int column) throws SQLException {
156 return 0;
157 }
158
159 /** Gets the designated column's number of digits to right of the decimal point.
160 *
161 * @param column the first column is 1, the second is 2, ...
162 * @return scale
163 * @exception SQLException if a database access error occurs
164 *
165 */
166 public int getScale(int column) throws SQLException {
167 return 0;
168 }
169
170 /** Get the designated column's table's schema.
171 *
172 * @param column the first column is 1, the second is 2, ...
173 * @return schema name or "" if not applicable
174 * @exception SQLException if a database access error occurs
175 *
176 */
177 public String getSchemaName(int column) throws SQLException {
178 return "no schema";
179 }
180
181 /** Gets the designated column's table name.
182 *
183 * @param column the first column is 1, the second is 2, ...
184 * @return table name or "" if not applicable
185 * @exception SQLException if a database access error occurs
186 *
187 */
188 public String getTableName(int column) throws SQLException {
189 return "undefined";
190 }
191
192 /** Indicates whether the designated column is automatically numbered, thus read-only.
193 *
194 * @param column the first column is 1, the second is 2, ...
195 * @return <code>true</code> if so; <code>false</code> otherwise
196 * @exception SQLException if a database access error occurs
197 *
198 */
199 public boolean isAutoIncrement(int column) throws SQLException {
200 return false;
201 }
202
203 /** Indicates whether a column's case matters.
204 *
205 * @param column the first column is 1, the second is 2, ...
206 * @return <code>true</code> if so; <code>false</code> otherwise
207 * @exception SQLException if a database access error occurs
208 *
209 */
210 public boolean isCaseSensitive(int column) throws SQLException {
211 return true;
212 }
213
214 /** Indicates whether the designated column is a cash value.
215 *
216 * @param column the first column is 1, the second is 2, ...
217 * @return <code>true</code> if so; <code>false</code> otherwise
218 * @exception SQLException if a database access error occurs
219 *
220 */
221 public boolean isCurrency(int column) throws SQLException {
222 return false;
223 }
224
225 /** Indicates whether a write on the designated column will definitely succeed.
226 *
227 * @param column the first column is 1, the second is 2, ...
228 * @return <code>true</code> if so; <code>false</code> otherwise
229 * @exception SQLException if a database access error occurs
230 *
231 */
232 public boolean isDefinitelyWritable(int column) throws SQLException {
233 return true;
234 }
235
236 /** Indicates the nullability of values in the designated column.
237 *
238 * @param column the first column is 1, the second is 2, ...
239 * @return the nullability status of the given column; one of <code>columnNoNulls</code>,
240 * <code>columnNullable</code> or <code>columnNullableUnknown</code>
241 * @exception SQLException if a database access error occurs
242 *
243 */
244 public int isNullable(int column) throws SQLException {
245 return this.columnNullable;
246 }
247
248 /** Indicates whether the designated column is definitely not writable.
249 *
250 * @param column the first column is 1, the second is 2, ...
251 * @return <code>true</code> if so; <code>false</code> otherwise
252 * @exception SQLException if a database access error occurs
253 *
254 */
255 public boolean isReadOnly(int column) throws SQLException {
256 return false;
257 }
258
259 /** Indicates whether the designated column can be used in a where clause.
260 *
261 * @param column the first column is 1, the second is 2, ...
262 * @return <code>true</code> if so; <code>false</code> otherwise
263 * @exception SQLException if a database access error occurs
264 *
265 */
266 public boolean isSearchable(int column) throws SQLException {
267 return true;
268 }
269
270 /** Indicates whether values in the designated column are signed numbers.
271 *
272 * @param column the first column is 1, the second is 2, ...
273 * @return <code>true</code> if so; <code>false</code> otherwise
274 * @exception SQLException if a database access error occurs
275 *
276 */
277 public boolean isSigned(int column) throws SQLException {
278 return false;
279 }
280
281 /** Indicates whether it is possible for a write on the designated column to succeed.
282 *
283 * @param column the first column is 1, the second is 2, ...
284 * @return <code>true</code> if so; <code>false</code> otherwise
285 * @exception SQLException if a database access error occurs
286 *
287 */
288 public boolean isWritable(int column) throws SQLException {
289 return true;
290 }
291 }