1
2 package org.webdocwf.util.xml;
3
4 import java.sql.ResultSetMetaData;
5 import java.sql.SQLException;
6 import java.sql.Types;
7
8 /***
9 *This class implements the ResultSetMetaData interface for the CsvJdbc driver.
10 *
11 * @author Jonathan Ackerman
12 * @author JD Evora
13 * @version $Id: XmlResultSetMetaData.html,v 1.1 2003/05/12 16:19:47 sinisa Exp $
14 */
15 public class XmlResultSetMetaData implements ResultSetMetaData
16 {
17 /*** Default value for getColumnDisplaySize */
18 final static int DISPLAY_SIZE = 20;
19 /*** Names of columns */
20 protected String[] columnNames;
21 /*** Name of table */
22 protected String tableName;
23
24 /***Constructor for the CsvResultSetMetaData object
25 *
26 * @param tableName Name of table
27 * @param columnNames Names of columns in table
28 */
29 XmlResultSetMetaData(String tableName, String[] columnNames)
30 {
31 this.tableName = tableName;
32 this.columnNames = columnNames;
33 }
34
35
36 /***Returns the name of the class for the specified column. Always returns
37 * String.
38 *
39 * @param column The column number
40 * @return The name of the class for the requested column
41 * @exception SQLException Thrown if there was a problem
42 */
43 public String getColumnClassName(int column) throws SQLException
44 {
45 return String.class.getName();
46 }
47
48
49 /*** Returns the number of columns in the table.
50 *
51 * @return The number of columns in the table
52 * @exception SQLException Thrown if there is a a problem
53 */
54 public int getColumnCount() throws SQLException
55 {
56 return columnNames.length;
57 }
58
59
60 /*** Returns the name of the catalog for the specified column. Returns "".
61 *
62 * @param column The column to get the catalog for
63 * @return The catalog name (always "")
64 * @exception SQLException Thrown if there is a problem
65 */
66 public String getCatalogName(int column) throws SQLException
67 {
68 return "";
69 }
70
71
72 /***Returns the display column size for the specified column. Always returns 20.
73 *
74 * @param column The column to get the size of
75 * @return The size of the requested column
76 * @exception SQLException Thrown if there is a problem.
77 */
78 public int getColumnDisplaySize(int column) throws SQLException
79 {
80 return DISPLAY_SIZE;
81 }
82
83
84 /***Gets the auto increment falg for the specfied column.
85 *
86 * @param column The column to get the flag for
87 * @return The autoIncrement flag (always false)
88 * @exception SQLException Thrown if there is a problem
89 */
90 public boolean isAutoIncrement(int column) throws SQLException
91 {
92 return false;
93 }
94
95
96 /***Returns the case sensitivity flag for the specfied column
97 *
98 * @param column The column to return the flag for
99 * @return The caseSensitive flag (always false)
100 * @exception SQLException Thrown if there is a problem
101 */
102 public boolean isCaseSensitive(int column) throws SQLException
103 {
104 //all columns are uppercase
105 return false;
106 }
107
108
109 /*** Returns the searchable flag for the specified column
110 *
111 * @param column the column to return the flag form
112 * @return The searchable flag (always false)
113 * @exception SQLException Thrown if there is a problem
114 */
115 public boolean isSearchable(int column) throws SQLException
116 {
117 // the implementation doesn't support the where clause
118 return true;
119 }
120
121
122 /***Returns the currency flag for the specified column
123 *
124 * @param column The column to get the flag for
125 * @return The currency flag (always false)
126 * @exception SQLException Thrown if there is a problem
127 */
128 public boolean isCurrency(int column) throws SQLException
129 {
130 return false;
131 }
132
133
134 /*** Returns the nullable flag for the specfied column
135 *
136 * @param column The column to return the flag for
137 * @return The nullable flag (always unknown)
138 * @exception SQLException Thrown if there is a problem
139 */
140 public int isNullable(int column) throws SQLException
141 {
142 return ResultSetMetaData.columnNullableUnknown;
143 }
144
145
146 /***Returns the signed flag for the specfied column
147 *
148 * @param column The column to return the flag for
149 * @return The signed flag (always false)
150 * @exception SQLException Thrown if there is a problem
151 */
152 public boolean isSigned(int column) throws SQLException
153 {
154 return false;
155 }
156
157
158 /*** Returns the label for the specified column
159 *
160 * @param column The column to get the label for
161 * @return the label for the specified column
162 * @exception SQLException Thrown if there is a problem
163 */
164 public String getColumnLabel(int column) throws SQLException
165 {
166 // SQL column numbers start at 1
167 return columnNames[column-1];
168 }
169
170
171 /***Returns the name of the specified column
172 *
173 * @param column The column to get the name of
174 * @return The name of the column
175 * @exception SQLException Thrown if there is a problem
176 */
177 public String getColumnName(int column) throws SQLException
178 {
179 // SQL column numbers start at 1
180 return columnNames[column-1];
181 }
182
183
184 /***Comments to be done
185 */
186 public String getSchemaName(int column) throws SQLException
187 {
188 return "";
189 }
190
191
192 /***Comments to be done
193 */
194 public int getPrecision(int column) throws SQLException
195 {
196 // All the fields are text, should this throw an SQLException?
197 return 0;
198 }
199
200
201 /***Comments to be done
202 */
203 public int getScale(int column) throws SQLException
204 {
205 // All the fields are text, should this throw an SQLException?
206 return 0;
207 }
208
209
210 /***Comments to be done
211 */
212 public String getTableName(int column) throws SQLException
213 {
214 return tableName;
215 }
216
217
218 /***Comments to be done
219 */
220 public int getColumnType(int column) throws SQLException
221 {
222 return Types.VARCHAR;
223 }
224
225
226 /***Comments to be done
227 */
228 public String getColumnTypeName(int column) throws SQLException
229 {
230 return String.class.getName();
231 }
232
233
234 /***Comments to be done
235 */
236 public boolean isReadOnly(int column) throws SQLException
237 {
238 return true;
239 }
240
241
242 /***Comments to be done
243 */
244 public boolean isWritable(int column) throws SQLException
245 {
246 return false;
247 }
248
249
250 /***Comments to be done
251 */
252 public boolean isDefinitelyWritable(int column) throws SQLException
253 {
254 return false;
255 }
256
257 }
258
This page automatically generated by Maven