1 19 20 package org.relique.jdbc.csv; 21 22 import java.sql.ResultSetMetaData ; 23 import java.sql.SQLException ; 24 import java.sql.Types ; 25 import java.util.Map ; 26 27 32 public class CsvResultSetMetaData implements ResultSetMetaData 33 { 34 35 final static int DISPLAY_SIZE = 20; 36 37 protected String [] columnNames; 38 39 protected Map columnTypes; 40 41 protected String tableName; 42 43 48 CsvResultSetMetaData(String tableName, String [] columnNames, Map columnTypes) 49 { 50 this.tableName = tableName; 51 this.columnNames = columnNames; 52 this.columnTypes = columnTypes; 53 } 54 55 56 63 public String getColumnClassName(int column) throws SQLException 64 { 65 return String .class.getName(); 66 } 67 68 69 74 public int getColumnCount() throws SQLException 75 { 76 return columnNames.length; 77 } 78 79 80 86 public String getCatalogName(int column) throws SQLException 87 { 88 return ""; 89 } 90 91 92 98 public int getColumnDisplaySize(int column) throws SQLException 99 { 100 return DISPLAY_SIZE; 101 } 102 103 104 110 public boolean isAutoIncrement(int column) throws SQLException 111 { 112 return false; 113 } 114 115 116 122 public boolean isCaseSensitive(int column) throws SQLException 123 { 124 return false; 126 } 127 128 129 135 public boolean isSearchable(int column) throws SQLException 136 { 137 return true; 138 } 139 140 141 147 public boolean isCurrency(int column) throws SQLException 148 { 149 return false; 150 } 151 152 153 159 public int isNullable(int column) throws SQLException 160 { 161 return ResultSetMetaData.columnNullableUnknown; 162 } 163 164 165 171 public boolean isSigned(int column) throws SQLException 172 { 173 return false; 174 } 175 176 177 183 public String getColumnLabel(int column) throws SQLException 184 { 185 return columnNames[column-1]; 187 } 188 189 190 196 public String getColumnName(int column) throws SQLException 197 { 198 return columnNames[column-1]; 200 } 201 202 203 205 public String getSchemaName(int column) throws SQLException 206 { 207 return ""; 208 } 209 210 211 213 public int getPrecision(int column) throws SQLException 214 { 215 return 0; 217 } 218 219 220 222 public int getScale(int column) throws SQLException 223 { 224 return 0; 226 } 227 228 229 231 public String getTableName(int column) throws SQLException 232 { 233 return tableName; 234 } 235 236 237 239 public int getColumnType(int column) throws SQLException 240 { 241 return Types.VARCHAR; 242 } 243 244 245 247 public String getColumnTypeName(int column) throws SQLException 248 { 249 return (String )columnTypes.get(columnNames[column-1]); 250 } 251 252 253 255 public boolean isReadOnly(int column) throws SQLException 256 { 257 return true; 258 } 259 260 261 263 public boolean isWritable(int column) throws SQLException 264 { 265 return false; 266 } 267 268 269 271 public boolean isDefinitelyWritable(int column) throws SQLException 272 { 273 return false; 274 } 275 276 } 277 278 | Popular Tags |