1 /*
2 Copyright (C) 2003 Together
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 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.webdocwf.util.xml;
20
21 import java.sql.ResultSetMetaData;
22 import java.sql.SQLException;
23 import java.sql.Types;
24
25 /***
26 * Class implements the JDBC ResultSetMetaData interface for the XmlJdbc driver.
27 *
28 * @author Zoran Milakovic
29 */
30 public class XmlResultSetMetaData implements ResultSetMetaData
31 {
32 /*** Default value for getColumnDisplaySize */
33 final static int DISPLAY_SIZE = 20;
34 /*** Names of columns */
35 protected String[] columnNames;
36 /*** Name of table */
37 protected String tableName;
38
39 /***Constructor for the XmlResultSetMetaData object
40 *
41 * @param tableName Name of table
42 * @param columnNames Names of columns in table
43 */
44 XmlResultSetMetaData(String tableName, String[] columnNames)
45 {
46 this.tableName = tableName;
47 this.columnNames = columnNames;
48 }
49
50
51 /***Returns the name of the class for the specified column. Always returns
52 * String.
53 *
54 * @param column The column number
55 * @return The name of the class for the requested column
56 * @exception SQLException Thrown if there was a problem
57 */
58 public String getColumnClassName(int column) throws SQLException
59 {
60 return String.class.getName();
61 }
62
63
64 /*** Returns the number of columns in the table.
65 *
66 * @return The number of columns in the table
67 * @exception SQLException Thrown if there is a a problem
68 */
69 public int getColumnCount() throws SQLException
70 {
71 return columnNames.length;
72 }
73
74
75 /*** Returns the name of the catalog for the specified column. Returns "".
76 *
77 * @param column The column to get the catalog for
78 * @return The catalog name (always "")
79 * @exception SQLException Thrown if there is a problem
80 */
81 public String getCatalogName(int column) throws SQLException
82 {
83 return "";
84 }
85
86
87 /***Returns the display column size for the specified column. Always returns 20.
88 *
89 * @param column The column to get the size of
90 * @return The size of the requested column
91 * @exception SQLException Thrown if there is a problem.
92 */
93 public int getColumnDisplaySize(int column) throws SQLException
94 {
95 return DISPLAY_SIZE;
96 }
97
98
99 /***Gets the auto increment falg for the specfied column.
100 *
101 * @param column The column to get the flag for
102 * @return The autoIncrement flag (always false)
103 * @exception SQLException Thrown if there is a problem
104 */
105 public boolean isAutoIncrement(int column) throws SQLException
106 {
107 return false;
108 }
109
110
111 /***Returns the case sensitivity flag for the specfied column
112 *
113 * @param column The column to return the flag for
114 * @return The caseSensitive flag (always false)
115 * @exception SQLException Thrown if there is a problem
116 */
117 public boolean isCaseSensitive(int column) throws SQLException
118 {
119 //all columns are uppercase
120 return false;
121 }
122
123
124 /*** Returns the searchable flag for the specified column
125 *
126 * @param column the column to return the flag form
127 * @return The searchable flag (always false)
128 * @exception SQLException Thrown if there is a problem
129 */
130 public boolean isSearchable(int column) throws SQLException
131 {
132 // the implementation doesn't support the where clause
133 return true;
134 }
135
136
137 /***Returns the currency flag for the specified column
138 *
139 * @param column The column to get the flag for
140 * @return The currency flag (always false)
141 * @exception SQLException Thrown if there is a problem
142 */
143 public boolean isCurrency(int column) throws SQLException
144 {
145 return false;
146 }
147
148
149 /*** Returns the nullable flag for the specfied column
150 *
151 * @param column The column to return the flag for
152 * @return The nullable flag (always unknown)
153 * @exception SQLException Thrown if there is a problem
154 */
155 public int isNullable(int column) throws SQLException
156 {
157 return ResultSetMetaData.columnNullableUnknown;
158 }
159
160
161 /***Returns the signed flag for the specfied column
162 *
163 * @param column The column to return the flag for
164 * @return The signed flag (always false)
165 * @exception SQLException Thrown if there is a problem
166 */
167 public boolean isSigned(int column) throws SQLException
168 {
169 return false;
170 }
171
172
173 /*** Returns the label for the specified column
174 *
175 * @param column The column to get the label for
176 * @return the label for the specified column
177 * @exception SQLException Thrown if there is a problem
178 */
179 public String getColumnLabel(int column) throws SQLException
180 {
181 // SQL column numbers start at 1
182 return columnNames[column-1];
183 }
184
185
186 /***Returns the name of the specified column
187 *
188 * @param column The column to get the name of
189 * @return The name of the column
190 * @exception SQLException Thrown if there is a problem
191 */
192 public String getColumnName(int column) throws SQLException
193 {
194 // SQL column numbers start at 1
195 return columnNames[column-1];
196 }
197
198
199 /***
200 * @param column is number of column
201 * @throws SQLException
202 * @return emty string
203 */
204 public String getSchemaName(int column) throws SQLException
205 {
206 return "";
207 }
208
209
210 /***
211 * @param column is number of column
212 * @throws SQLException
213 * @return 0
214 */
215 public int getPrecision(int column) throws SQLException
216 {
217 // All the fields are text, should this throw an SQLException?
218 return 0;
219 }
220
221
222 /***
223 * @param column is number of column
224 * @throws SQLException
225 * @return 0
226 */
227 public int getScale(int column) throws SQLException
228 {
229 // All the fields are text, should this throw an SQLException?
230 return 0;
231 }
232
233
234 /***
235 * @param column is number of column
236 * @throws SQLException
237 * @return table name
238 */
239 public String getTableName(int column) throws SQLException
240 {
241 return tableName;
242 }
243
244
245 /***
246 * @param column is number of column
247 * @throws SQLException
248 * @return VARCHAR (type of data)
249 */
250 public int getColumnType(int column) throws SQLException
251 {
252 return Types.VARCHAR;
253 }
254
255
256 /***
257 * @param column is number of column
258 * @throws SQLException
259 * @return name of the class
260 */
261 public String getColumnTypeName(int column) throws SQLException
262 {
263 return "VARCHAR";
264 }
265
266
267 /***
268 * @param column is number of column
269 * @throws SQLException
270 * @return true
271 */
272 public boolean isReadOnly(int column) throws SQLException
273 {
274 return true;
275 }
276
277
278 /***
279 * @param column is number of column
280 * @throws SQLException
281 * @return false
282 */
283 public boolean isWritable(int column) throws SQLException
284 {
285 return false;
286 }
287
288
289 /***
290 * @param column is number of column
291 * @throws SQLException
292 * @return false
293 */
294 public boolean isDefinitelyWritable(int column) throws SQLException
295 {
296 return false;
297 }
298
299 }
300
This page was automatically generated by Maven