View Javadoc
1 /*** 2 Copyright (C) 2002-2003 Together 3 4 This library is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Lesser General Public 6 License as published by the Free Software Foundation; either 7 version 2.1 of the License, or (at your option) any later version. 8 9 This library is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Lesser General Public License for more details. 13 14 You should have received a copy of the GNU Lesser General Public 15 License along with this library; if not, write to the Free Software 16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 18 */ 19 20 package org.webdocwf.util.i18njdbc; 21 22 import java.sql.ResultSetMetaData; 23 import java.sql.SQLException; 24 import java.sql.Types; 25 26 /*** 27 *This class implements the ResultSetMetaData interface for the CsvJdbc driver. 28 * 29 * @author Zoran Milakovic 30 * @author Zeljko Kovacevic 31 */ 32 public class I18nResultSetMetaData implements ResultSetMetaData 33 { 34 /*** Default value for getColumnDisplaySize */ 35 final static int DISPLAY_SIZE = 20; 36 /*** Names of columns */ 37 protected String[] columnNames; 38 /*** Types of columns */ 39 protected String[] columnTypes; 40 /*** Name of table */ 41 protected String tableName; 42 43 /***Constructor for the CsvResultSetMetaData object 44 * 45 * @param tableName Name of table 46 * @param columnNames Names of columns in table 47 */ 48 I18nResultSetMetaData(String tableName, String[] columnNames, String[] columnTypes) 49 { 50 this.tableName = tableName; 51 this.columnNames = columnNames; 52 this.columnTypes = columnTypes; 53 } 54 55 56 /***Returns the name of the class for the specified column. Always returns 57 * String. 58 * 59 * @param column The column number 60 * @return The name of the class for the requested column 61 * @exception SQLException Thrown if there was a problem 62 */ 63 public String getColumnClassName(int column) throws SQLException 64 { 65 return String.class.getName(); 66 } 67 68 69 /*** Returns the number of columns in the table. 70 * 71 * @return The number of columns in the table 72 * @exception SQLException Thrown if there is a a problem 73 */ 74 public int getColumnCount() throws SQLException 75 { 76 return columnNames.length; 77 } 78 79 80 /*** Returns the name of the catalog for the specified column. Returns "". 81 * 82 * @param column The column to get the catalog for 83 * @return The catalog name (always "") 84 * @exception SQLException Thrown if there is a problem 85 */ 86 public String getCatalogName(int column) throws SQLException 87 { 88 return ""; 89 } 90 91 92 /***Returns the display column size for the specified column. Always returns 20. 93 * 94 * @param column The column to get the size of 95 * @return The size of the requested column 96 * @exception SQLException Thrown if there is a problem. 97 */ 98 public int getColumnDisplaySize(int column) throws SQLException 99 { 100 return DISPLAY_SIZE; 101 } 102 103 104 /***Gets the auto increment falg for the specfied column. 105 * 106 * @param column The column to get the flag for 107 * @return The autoIncrement flag (always false) 108 * @exception SQLException Thrown if there is a problem 109 */ 110 public boolean isAutoIncrement(int column) throws SQLException 111 { 112 return false; 113 } 114 115 116 /***Returns the case sensitivity flag for the specfied column 117 * 118 * @param column The column to return the flag for 119 * @return The caseSensitive flag (always false) 120 * @exception SQLException Thrown if there is a problem 121 */ 122 public boolean isCaseSensitive(int column) throws SQLException 123 { 124 //all columns are uppercase 125 return false; 126 } 127 128 129 /*** Returns the searchable flag for the specified column 130 * 131 * @param column the column to return the flag form 132 * @return The searchable flag (always false) 133 * @exception SQLException Thrown if there is a problem 134 */ 135 public boolean isSearchable(int column) throws SQLException 136 { 137 return true; 138 } 139 140 141 /***Returns the currency flag for the specified column 142 * 143 * @param column The column to get the flag for 144 * @return The currency flag (always false) 145 * @exception SQLException Thrown if there is a problem 146 */ 147 public boolean isCurrency(int column) throws SQLException 148 { 149 return false; 150 } 151 152 153 /*** Returns the nullable flag for the specfied column 154 * 155 * @param column The column to return the flag for 156 * @return The nullable flag (always unknown) 157 * @exception SQLException Thrown if there is a problem 158 */ 159 public int isNullable(int column) throws SQLException 160 { 161 return ResultSetMetaData.columnNullableUnknown; 162 } 163 164 165 /***Returns the signed flag for the specfied column 166 * 167 * @param column The column to return the flag for 168 * @return The signed flag (always false) 169 * @exception SQLException Thrown if there is a problem 170 */ 171 public boolean isSigned(int column) throws SQLException 172 { 173 return false; 174 } 175 176 177 /*** Returns the label for the specified column 178 * 179 * @param column The column to get the label for 180 * @return the label for the specified column 181 * @exception SQLException Thrown if there is a problem 182 */ 183 public String getColumnLabel(int column) throws SQLException 184 { 185 // SQL column numbers start at 1 186 return columnNames[column-1]; 187 } 188 189 190 /***Returns the name of the specified column 191 * 192 * @param column The column to get the name of 193 * @return The name of the column 194 * @exception SQLException Thrown if there is a problem 195 */ 196 public String getColumnName(int column) throws SQLException 197 { 198 // SQL column numbers start at 1 199 return columnNames[column-1]; 200 } 201 202 203 /***Comments to be done 204 */ 205 public String getSchemaName(int column) throws SQLException 206 { 207 return ""; 208 } 209 210 211 /***Comments to be done 212 */ 213 public int getPrecision(int column) throws SQLException 214 { 215 // All the fields are text, should this throw an SQLException? 216 return 0; 217 } 218 219 220 /***Comments to be done 221 */ 222 public int getScale(int column) throws SQLException 223 { 224 // All the fields are text, should this throw an SQLException? 225 return 0; 226 } 227 228 229 /***Comments to be done 230 */ 231 public String getTableName(int column) throws SQLException 232 { 233 return tableName; 234 } 235 236 237 /***Comments to be done 238 */ 239 public int getColumnType(int column) throws SQLException 240 { 241 return Types.VARCHAR; 242 } 243 244 245 /***Comments to be done 246 */ 247 public String getColumnTypeName(int column) throws SQLException 248 { 249 return "VARCHAR"; 250 } 251 252 253 /***Comments to be done 254 */ 255 public boolean isReadOnly(int column) throws SQLException 256 { 257 return true; 258 } 259 260 261 /***Comments to be done 262 */ 263 public boolean isWritable(int column) throws SQLException 264 { 265 return false; 266 } 267 268 269 /***Comments to be done 270 */ 271 public boolean isDefinitelyWritable(int column) throws SQLException 272 { 273 return false; 274 } 275 276 } 277

This page was automatically generated by Maven