001: /**
002: * Sequoia: Database clustering technology.
003: * Copyright (C) 2002-2004 French National Institute For Research In Computer
004: * Science And Control (INRIA).
005: * Contact: sequoia@continuent.org
006: *
007: * Licensed under the Apache License, Version 2.0 (the "License");
008: * you may not use this file except in compliance with the License.
009: * You may obtain a copy of the License at
010: *
011: * http://www.apache.org/licenses/LICENSE-2.0
012: *
013: * Unless required by applicable law or agreed to in writing, software
014: * distributed under the License is distributed on an "AS IS" BASIS,
015: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016: * See the License for the specific language governing permissions and
017: * limitations under the License.
018: *
019: * Initial developer(s): Emmanuel Cecchet.
020: * Contributor(s): __________________.
021: */package org.continuent.sequoia.driver;
022:
023: import java.sql.SQLException;
024:
025: /**
026: * ResultSet metadata provided for pretty printing of the ResultSet by a
027: * console.
028: *
029: * @author <a href="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet</a>
030: * @version 1.0
031: */
032: public class ResultSetMetaData implements java.sql.ResultSetMetaData {
033: private DriverResultSet rs;
034:
035: /**
036: * Constructs a ResultSetMetaData from a Sequoia ResultSet.
037: *
038: * @param rs the ResultSet
039: */
040: public ResultSetMetaData(DriverResultSet rs) {
041: this .rs = rs;
042: }
043:
044: /**
045: * @see java.sql.ResultSetMetaData#getColumnCount()
046: */
047: public int getColumnCount() throws SQLException {
048: return rs.nbOfColumns;
049: }
050:
051: /**
052: * @see java.sql.ResultSetMetaData#isAutoIncrement(int)
053: */
054: public boolean isAutoIncrement(int column) throws SQLException {
055: if ((column < 1) || (column > rs.nbOfColumns))
056: throw new SQLException("Invalid column index " + column);
057: return rs.fields[column - 1].isAutoIncrement();
058: }
059:
060: /**
061: * @see java.sql.ResultSetMetaData#isCaseSensitive(int)
062: */
063: public boolean isCaseSensitive(int column) throws SQLException {
064: if ((column < 1) || (column > rs.nbOfColumns))
065: throw new SQLException("Invalid column index " + column);
066: return rs.fields[column - 1].isCaseSensitive();
067: }
068:
069: /**
070: * @see java.sql.ResultSetMetaData#isSearchable(int)
071: */
072: public boolean isSearchable(int column) throws SQLException {
073: if ((column < 1) || (column > rs.nbOfColumns))
074: throw new SQLException("Invalid column index " + column);
075: return rs.fields[column - 1].isSearchable();
076: }
077:
078: /**
079: * @see java.sql.ResultSetMetaData#isCurrency(int)
080: */
081: public boolean isCurrency(int column) throws SQLException {
082: if ((column < 1) || (column > rs.nbOfColumns))
083: throw new SQLException("Invalid column index " + column);
084: return rs.fields[column - 1].isCurrency();
085: }
086:
087: /**
088: * @see java.sql.ResultSetMetaData#isNullable(int)
089: */
090: public int isNullable(int column) throws SQLException {
091: if ((column < 1) || (column > rs.nbOfColumns))
092: throw new SQLException("Invalid column index " + column);
093: return rs.fields[column - 1].isNullable();
094: }
095:
096: /**
097: * @see java.sql.ResultSetMetaData#isSigned(int)
098: */
099: public boolean isSigned(int column) throws SQLException {
100: if ((column < 1) || (column > rs.nbOfColumns))
101: throw new SQLException("Invalid column index " + column);
102: return rs.fields[column - 1].isSigned();
103: }
104:
105: /**
106: * @see java.sql.ResultSetMetaData#getColumnDisplaySize(int)
107: */
108: public int getColumnDisplaySize(int column) throws SQLException {
109: if ((column < 1) || (column > rs.nbOfColumns))
110: throw new SQLException("Invalid column index " + column);
111: return rs.fields[column - 1].getColumnDisplaySize();
112: }
113:
114: /**
115: * @see java.sql.ResultSetMetaData#getColumnLabel(int)
116: */
117: public String getColumnLabel(int column) throws SQLException {
118: if ((column < 1) || (column > rs.nbOfColumns))
119: throw new SQLException("Invalid column index " + column);
120: return rs.fields[column - 1].getFieldLabel();
121: }
122:
123: /**
124: * @see java.sql.ResultSetMetaData#getColumnName(int)
125: */
126: public String getColumnName(int column) throws SQLException {
127: if ((column < 1) || (column > rs.nbOfColumns))
128: throw new SQLException("Invalid column index " + column);
129: return rs.fields[column - 1].getFieldName();
130: }
131:
132: /**
133: * @see java.sql.ResultSetMetaData#getSchemaName(int)
134: */
135: public String getSchemaName(int column) throws SQLException {
136: if ((column < 1) || (column > rs.nbOfColumns))
137: throw new SQLException("Invalid column index " + column);
138: return rs.fields[column - 1].getFullName();
139: }
140:
141: /**
142: * @see java.sql.ResultSetMetaData#getPrecision(int)
143: */
144: public int getPrecision(int column) throws SQLException {
145: if ((column < 1) || (column > rs.nbOfColumns))
146: throw new SQLException("Invalid column index " + column);
147: return rs.fields[column - 1].getPrecision();
148: }
149:
150: /**
151: * @see java.sql.ResultSetMetaData#getScale(int)
152: */
153: public int getScale(int column) throws SQLException {
154: if ((column < 1) || (column > rs.nbOfColumns))
155: throw new SQLException("Invalid column index " + column);
156: return rs.fields[column - 1].getScale();
157: }
158:
159: /**
160: * @see java.sql.ResultSetMetaData#getTableName(int)
161: */
162: public String getTableName(int column) throws SQLException {
163: if ((column < 1) || (column > rs.nbOfColumns))
164: throw new SQLException("Invalid column index " + column);
165: return rs.fields[column - 1].getTableName();
166: }
167:
168: /**
169: * @see java.sql.ResultSetMetaData#getCatalogName(int)
170: */
171: public String getCatalogName(int column) throws SQLException {
172: if ((column < 1) || (column > rs.nbOfColumns))
173: throw new SQLException("Invalid column index " + column);
174: return "";
175: }
176:
177: /**
178: * @see java.sql.ResultSetMetaData#getColumnType(int)
179: */
180: public int getColumnType(int column) throws SQLException {
181: if ((column < 1) || (column > rs.nbOfColumns))
182: throw new SQLException("Invalid column index " + column);
183: return rs.fields[column - 1].getSqlType();
184: }
185:
186: /**
187: * @see java.sql.ResultSetMetaData#getColumnTypeName(int)
188: */
189: public String getColumnTypeName(int column) throws SQLException {
190: if ((column < 1) || (column > rs.nbOfColumns))
191: throw new SQLException("Invalid column index " + column);
192: return rs.fields[column - 1].getTypeName();
193: }
194:
195: /**
196: * @see java.sql.ResultSetMetaData#isReadOnly(int)
197: */
198: public boolean isReadOnly(int column) throws SQLException {
199: if ((column < 1) || (column > rs.nbOfColumns))
200: throw new SQLException("Invalid column index " + column);
201: return rs.fields[column - 1].isReadOnly();
202: }
203:
204: /**
205: * @see java.sql.ResultSetMetaData#isWritable(int)
206: */
207: public boolean isWritable(int column) throws SQLException {
208: if ((column < 1) || (column > rs.nbOfColumns))
209: throw new SQLException("Invalid column index " + column);
210: return rs.fields[column - 1].isWritable();
211: }
212:
213: /**
214: * @see java.sql.ResultSetMetaData#isDefinitelyWritable(int)
215: */
216: public boolean isDefinitelyWritable(int column) throws SQLException {
217: if ((column < 1) || (column > rs.nbOfColumns))
218: throw new SQLException("Invalid column index " + column);
219: return rs.fields[column - 1].isDefinitelyWritable();
220: }
221:
222: /**
223: * @see java.sql.ResultSetMetaData#getColumnClassName(int)
224: */
225: public String getColumnClassName(int column) throws SQLException {
226: if ((column < 1) || (column > rs.nbOfColumns))
227: throw new SQLException("Invalid column index " + column);
228: return rs.fields[column - 1].getColumnClassName();
229: }
230:
231: }
|