001: /**
002: Copyright (C) 2002-2003 Together
003:
004: This library is free software; you can redistribute it and/or
005: modify it under the terms of the GNU Lesser General Public
006: License as published by the Free Software Foundation; either
007: version 2.1 of the License, or (at your option) any later version.
008:
009: This library is distributed in the hope that it will be useful,
010: but WITHOUT ANY WARRANTY; without even the implied warranty of
011: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: Lesser General Public License for more details.
013:
014: You should have received a copy of the GNU Lesser General Public
015: License along with this library; if not, write to the Free Software
016: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017:
018: */package org.webdocwf.util.i18njdbc;
019:
020: import java.sql.ResultSetMetaData;
021: import java.sql.SQLException;
022: import java.sql.Types;
023:
024: /**
025: *This class implements the ResultSetMetaData interface for the CsvJdbc driver.
026: *
027: * @author Zoran Milakovic
028: * @author Zeljko Kovacevic
029: */
030: public class I18nResultSetMetaData implements ResultSetMetaData {
031: /** Default value for getColumnDisplaySize */
032: final static int DISPLAY_SIZE = 20;
033: /** Names of columns */
034: protected String[] columnNames;
035: /** Types of columns */
036: protected String[] columnTypes;
037: /** Name of table */
038: protected String tableName;
039:
040: /**Constructor for the CsvResultSetMetaData object
041: *
042: * @param tableName Name of table
043: * @param columnNames Names of columns in table
044: */
045: I18nResultSetMetaData(String tableName, String[] columnNames,
046: String[] columnTypes) {
047: this .tableName = tableName;
048: this .columnNames = columnNames;
049: this .columnTypes = columnTypes;
050: }
051:
052: /**Returns the name of the class for the specified column. Always returns
053: * String.
054: *
055: * @param column The column number
056: * @return The name of the class for the requested column
057: * @exception SQLException Thrown if there was a problem
058: */
059: public String getColumnClassName(int column) throws SQLException {
060: return String.class.getName();
061: }
062:
063: /** Returns the number of columns in the table.
064: *
065: * @return The number of columns in the table
066: * @exception SQLException Thrown if there is a a problem
067: */
068: public int getColumnCount() throws SQLException {
069: return columnNames.length;
070: }
071:
072: /** Returns the name of the catalog for the specified column. Returns "".
073: *
074: * @param column The column to get the catalog for
075: * @return The catalog name (always "")
076: * @exception SQLException Thrown if there is a problem
077: */
078: public String getCatalogName(int column) throws SQLException {
079: return "";
080: }
081:
082: /**Returns the display column size for the specified column. Always returns 20.
083: *
084: * @param column The column to get the size of
085: * @return The size of the requested column
086: * @exception SQLException Thrown if there is a problem.
087: */
088: public int getColumnDisplaySize(int column) throws SQLException {
089: return DISPLAY_SIZE;
090: }
091:
092: /**Gets the auto increment falg for the specfied column.
093: *
094: * @param column The column to get the flag for
095: * @return The autoIncrement flag (always false)
096: * @exception SQLException Thrown if there is a problem
097: */
098: public boolean isAutoIncrement(int column) throws SQLException {
099: return false;
100: }
101:
102: /**Returns the case sensitivity flag for the specfied column
103: *
104: * @param column The column to return the flag for
105: * @return The caseSensitive flag (always false)
106: * @exception SQLException Thrown if there is a problem
107: */
108: public boolean isCaseSensitive(int column) throws SQLException {
109: //all columns are uppercase
110: return false;
111: }
112:
113: /** Returns the searchable flag for the specified column
114: *
115: * @param column the column to return the flag form
116: * @return The searchable flag (always false)
117: * @exception SQLException Thrown if there is a problem
118: */
119: public boolean isSearchable(int column) throws SQLException {
120: return true;
121: }
122:
123: /**Returns the currency flag for the specified column
124: *
125: * @param column The column to get the flag for
126: * @return The currency flag (always false)
127: * @exception SQLException Thrown if there is a problem
128: */
129: public boolean isCurrency(int column) throws SQLException {
130: return false;
131: }
132:
133: /** Returns the nullable flag for the specfied column
134: *
135: * @param column The column to return the flag for
136: * @return The nullable flag (always unknown)
137: * @exception SQLException Thrown if there is a problem
138: */
139: public int isNullable(int column) throws SQLException {
140: return ResultSetMetaData.columnNullableUnknown;
141: }
142:
143: /**Returns the signed flag for the specfied column
144: *
145: * @param column The column to return the flag for
146: * @return The signed flag (always false)
147: * @exception SQLException Thrown if there is a problem
148: */
149: public boolean isSigned(int column) throws SQLException {
150: return false;
151: }
152:
153: /** Returns the label for the specified column
154: *
155: * @param column The column to get the label for
156: * @return the label for the specified column
157: * @exception SQLException Thrown if there is a problem
158: */
159: public String getColumnLabel(int column) throws SQLException {
160: // SQL column numbers start at 1
161: return columnNames[column - 1];
162: }
163:
164: /**Returns the name of the specified column
165: *
166: * @param column The column to get the name of
167: * @return The name of the column
168: * @exception SQLException Thrown if there is a problem
169: */
170: public String getColumnName(int column) throws SQLException {
171: // SQL column numbers start at 1
172: return columnNames[column - 1];
173: }
174:
175: /**Comments to be done
176: */
177: public String getSchemaName(int column) throws SQLException {
178: return "";
179: }
180:
181: /**Comments to be done
182: */
183: public int getPrecision(int column) throws SQLException {
184: // All the fields are text, should this throw an SQLException?
185: return 0;
186: }
187:
188: /**Comments to be done
189: */
190: public int getScale(int column) throws SQLException {
191: // All the fields are text, should this throw an SQLException?
192: return 0;
193: }
194:
195: /**Comments to be done
196: */
197: public String getTableName(int column) throws SQLException {
198: return tableName;
199: }
200:
201: /**Comments to be done
202: */
203: public int getColumnType(int column) throws SQLException {
204: return Types.VARCHAR;
205: }
206:
207: /**Comments to be done
208: */
209: public String getColumnTypeName(int column) throws SQLException {
210: return "VARCHAR";
211: }
212:
213: /**Comments to be done
214: */
215: public boolean isReadOnly(int column) throws SQLException {
216: return true;
217: }
218:
219: /**Comments to be done
220: */
221: public boolean isWritable(int column) throws SQLException {
222: return false;
223: }
224:
225: /**Comments to be done
226: */
227: public boolean isDefinitelyWritable(int column) throws SQLException {
228: return false;
229: }
230:
231: public boolean isWrapperFor(Class<?> iface) throws SQLException {
232: // TODO Auto-generated method stub
233: return false;
234: }
235:
236: public <T> T unwrap(Class<T> iface) throws SQLException {
237: // TODO Auto-generated method stub
238: return null;
239: }
240:
241: }
|