KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > continuent > sequoia > driver > ResultSetMetaData


1 /**
2  * Sequoia: Database clustering technology.
3  * Copyright (C) 2002-2004 French National Institute For Research In Computer
4  * Science And Control (INRIA).
5  * Contact: sequoia@continuent.org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  * Initial developer(s): Emmanuel Cecchet.
20  * Contributor(s): __________________.
21  */

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

34 public class ResultSetMetaData implements java.sql.ResultSetMetaData JavaDoc
35 {
36   private DriverResultSet rs;
37
38   /**
39    * Constructs a ResultSetMetaData from a Sequoia ResultSet.
40    *
41    * @param rs the ResultSet
42    */

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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