KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > driver > ResultSetMetaData


1 /**
2  * C-JDBC: Clustered JDBC.
3  * Copyright (C) 2002-2004 French National Institute For Research In Computer
4  * Science And Control (INRIA).
5  * Contact: c-jdbc@objectweb.org
6  *
7  * This library is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by the
9  * Free Software Foundation; either version 2.1 of the License, or any later
10  * version.
11  *
12  * This library is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library; if not, write to the Free Software Foundation,
19  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20  *
21  * Initial developer(s): Emmanuel Cecchet.
22  * Contributor(s): __________________.
23  */

24
25 package org.objectweb.cjdbc.driver;
26
27 import java.sql.SQLException JavaDoc;
28
29 /**
30  * ResultSet metadata provided for pretty printing of the ResultSet by a
31  * console.
32  *
33  * @author <a HREF="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet</a>
34  * @version 1.0
35  */

36 public class ResultSetMetaData implements java.sql.ResultSetMetaData JavaDoc
37 {
38   private DriverResultSet rs;
39
40   /**
41    * Constructs a ResultSetMetaData from a C-JDBC ResultSet.
42    *
43    * @param rs the ResultSet
44    */

45   public ResultSetMetaData(DriverResultSet rs)
46   {
47     this.rs = rs;
48   }
49
50   /**
51    * @see java.sql.ResultSetMetaData#getColumnCount()
52    */

53   public int getColumnCount() throws SQLException JavaDoc
54   {
55     return rs.nbOfColumns;
56   }
57
58   /**
59    * @see java.sql.ResultSetMetaData#isAutoIncrement(int)
60    */

61   public boolean isAutoIncrement(int column) throws SQLException JavaDoc
62   {
63     if ((column < 1) || (column > rs.nbOfColumns))
64       throw new SQLException JavaDoc("Invalid column index " + column);
65     return rs.fields[column - 1].isAutoIncrement();
66   }
67
68   /**
69    * @see java.sql.ResultSetMetaData#isCaseSensitive(int)
70    */

71   public boolean isCaseSensitive(int column) throws SQLException JavaDoc
72   {
73     if ((column < 1) || (column > rs.nbOfColumns))
74       throw new SQLException JavaDoc("Invalid column index " + column);
75     return rs.fields[column - 1].isCaseSensitive();
76   }
77
78   /**
79    * @see java.sql.ResultSetMetaData#isSearchable(int)
80    */

81   public boolean isSearchable(int column) throws SQLException JavaDoc
82   {
83     if ((column < 1) || (column > rs.nbOfColumns))
84       throw new SQLException JavaDoc("Invalid column index " + column);
85     return rs.fields[column - 1].isSearchable();
86   }
87
88   /**
89    * @see java.sql.ResultSetMetaData#isCurrency(int)
90    */

91   public boolean isCurrency(int column) throws SQLException JavaDoc
92   {
93     if ((column < 1) || (column > rs.nbOfColumns))
94       throw new SQLException JavaDoc("Invalid column index " + column);
95     return rs.fields[column - 1].isCurrency();
96   }
97
98   /**
99    * @see java.sql.ResultSetMetaData#isNullable(int)
100    */

101   public int isNullable(int column) throws SQLException JavaDoc
102   {
103     if ((column < 1) || (column > rs.nbOfColumns))
104       throw new SQLException JavaDoc("Invalid column index " + column);
105     return rs.fields[column - 1].isNullable();
106   }
107
108   /**
109    * @see java.sql.ResultSetMetaData#isSigned(int)
110    */

111   public boolean isSigned(int column) throws SQLException JavaDoc
112   {
113     if ((column < 1) || (column > rs.nbOfColumns))
114       throw new SQLException JavaDoc("Invalid column index " + column);
115     return rs.fields[column - 1].isSigned();
116   }
117
118   /**
119    * @see java.sql.ResultSetMetaData#getColumnDisplaySize(int)
120    */

121   public int getColumnDisplaySize(int column) throws SQLException JavaDoc
122   {
123     if ((column < 1) || (column > rs.nbOfColumns))
124       throw new SQLException JavaDoc("Invalid column index " + column);
125     return rs.fields[column - 1].getColumnDisplaySize();
126   }
127
128   /**
129    * @see java.sql.ResultSetMetaData#getColumnLabel(int)
130    */

131   public String JavaDoc getColumnLabel(int column) throws SQLException JavaDoc
132   {
133     if ((column < 1) || (column > rs.nbOfColumns))
134       throw new SQLException JavaDoc("Invalid column index " + column);
135     return rs.fields[column - 1].getFieldName();
136   }
137
138   /**
139    * @see java.sql.ResultSetMetaData#getColumnName(int)
140    */

141   public String JavaDoc getColumnName(int column) throws SQLException JavaDoc
142   {
143     if ((column < 1) || (column > rs.nbOfColumns))
144       throw new SQLException JavaDoc("Invalid column index " + column);
145     return rs.fields[column - 1].getFieldName();
146   }
147
148   /**
149    * @see java.sql.ResultSetMetaData#getSchemaName(int)
150    */

151   public String JavaDoc getSchemaName(int column) throws SQLException JavaDoc
152   {
153     if ((column < 1) || (column > rs.nbOfColumns))
154       throw new SQLException JavaDoc("Invalid column index " + column);
155     return rs.fields[column - 1].getFullName();
156   }
157
158   /**
159    * @see java.sql.ResultSetMetaData#getPrecision(int)
160    */

161   public int getPrecision(int column) throws SQLException JavaDoc
162   {
163     if ((column < 1) || (column > rs.nbOfColumns))
164       throw new SQLException JavaDoc("Invalid column index " + column);
165     return rs.fields[column - 1].getPrecision();
166   }
167
168   /**
169    * @see java.sql.ResultSetMetaData#getScale(int)
170    */

171   public int getScale(int column) throws SQLException JavaDoc
172   {
173     if ((column < 1) || (column > rs.nbOfColumns))
174       throw new SQLException JavaDoc("Invalid column index " + column);
175     return rs.fields[column - 1].getScale();
176   }
177
178   /**
179    * @see java.sql.ResultSetMetaData#getTableName(int)
180    */

181   public String JavaDoc getTableName(int column) throws SQLException JavaDoc
182   {
183     if ((column < 1) || (column > rs.nbOfColumns))
184       throw new SQLException JavaDoc("Invalid column index " + column);
185     return rs.fields[column - 1].getTableName();
186   }
187
188   /**
189    * @see java.sql.ResultSetMetaData#getCatalogName(int)
190    */

191   public String JavaDoc getCatalogName(int column) throws SQLException JavaDoc
192   {
193     if ((column < 1) || (column > rs.nbOfColumns))
194       throw new SQLException JavaDoc("Invalid column index " + column);
195     return "";
196   }
197
198   /**
199    * @see java.sql.ResultSetMetaData#getColumnType(int)
200    */

201   public int getColumnType(int column) throws SQLException JavaDoc
202   {
203     if ((column < 1) || (column > rs.nbOfColumns))
204       throw new SQLException JavaDoc("Invalid column index " + column);
205     return rs.fields[column - 1].getSqlType();
206   }
207
208   /**
209    * @see java.sql.ResultSetMetaData#getColumnTypeName(int)
210    */

211   public String JavaDoc getColumnTypeName(int column) throws SQLException JavaDoc
212   {
213     if ((column < 1) || (column > rs.nbOfColumns))
214       throw new SQLException JavaDoc("Invalid column index " + column);
215     return rs.fields[column - 1].getTypeName();
216   }
217
218   /**
219    * @see java.sql.ResultSetMetaData#isReadOnly(int)
220    */

221   public boolean isReadOnly(int column) throws SQLException JavaDoc
222   {
223     if ((column < 1) || (column > rs.nbOfColumns))
224       throw new SQLException JavaDoc("Invalid column index " + column);
225     return rs.fields[column - 1].isReadOnly();
226   }
227
228   /**
229    * @see java.sql.ResultSetMetaData#isWritable(int)
230    */

231   public boolean isWritable(int column) throws SQLException JavaDoc
232   {
233     if ((column < 1) || (column > rs.nbOfColumns))
234       throw new SQLException JavaDoc("Invalid column index " + column);
235     return rs.fields[column - 1].isWritable();
236   }
237
238   /**
239    * @see java.sql.ResultSetMetaData#isDefinitelyWritable(int)
240    */

241   public boolean isDefinitelyWritable(int column) throws SQLException JavaDoc
242   {
243     if ((column < 1) || (column > rs.nbOfColumns))
244       throw new SQLException JavaDoc("Invalid column index " + column);
245     return rs.fields[column - 1].isDefinitelyWritable();
246   }
247
248   /**
249    * @see java.sql.ResultSetMetaData#getColumnClassName(int)
250    */

251   public String JavaDoc getColumnClassName(int column) throws SQLException JavaDoc
252   {
253     if ((column < 1) || (column > rs.nbOfColumns))
254       throw new SQLException JavaDoc("Invalid column index " + column);
255     return rs.fields[column - 1].getColumnClassName();
256   }
257
258 }
259
Popular Tags