1 package com.quadcap.jdbc; 2 3 40 41 import java.sql.SQLException ; 42 43 import com.quadcap.sql.Column; 44 import com.quadcap.sql.Cursor; 45 import com.quadcap.sql.Tuple; 46 47 import com.quadcap.sql.types.Type; 48 49 import com.quadcap.util.Debug; 50 51 58 public class ResultSetMetaData implements java.sql.ResultSetMetaData { 59 Cursor cursor; 60 61 64 public ResultSetMetaData(Cursor cursor) { 65 this.cursor = cursor; 66 } 67 68 71 public String getCatalogName(int column) throws SQLException { 72 return ""; 73 } 74 75 83 public String getColumnClassName(int column) throws SQLException { 84 return getType(column).getJDBCClassName(); 85 } 86 87 93 public int getColumnCount() throws SQLException { 94 return cursor.getColumnCount(); 95 } 96 97 105 public int getColumnDisplaySize(int column) throws SQLException { 106 Column col = cursor.getColumn(column); 107 int w2; 108 if (col.getType() != null) { 109 w2 = col.getType().getDisplayWidth(); 110 } else { 111 w2 = col.getShortName().length(); 112 } 113 return w2; 114 } 115 116 124 public String getColumnLabel(int column) throws SQLException { 125 return cursor.getColumn(column).getShortName(); 126 } 127 128 136 public String getColumnName(int column) throws SQLException { 137 return cursor.getColumn(column).getShortName(); 138 } 139 140 147 public int getColumnType(int column) throws SQLException { 148 return getType(column).getJDBCType(); 149 } 150 151 158 public String getColumnTypeName(int column) throws SQLException { 159 return getType(column).getTypeName(); 160 } 161 162 170 public int getPrecision(int column) throws SQLException { 171 return getType(column).getPrecision(); 172 } 173 174 182 public int getScale(int column) throws SQLException { 183 return getType(column).getScale(); 184 } 185 186 195 public String getSchemaName(int column) throws SQLException { 196 String s = cursor.getColumn(column).getName(); 197 int idx = s.indexOf('.'); 198 if (idx >= 0) { 199 return s.substring(0, idx); 200 } else { 201 return ""; 202 } 203 } 204 205 212 public String getTableName(int column) throws SQLException { 213 String ret = ""; 214 Tuple table = cursor.getColumn(column).getRelation(); 215 if (table != null) ret = table.getName(); 216 return ret; 217 } 218 219 226 public boolean isAutoIncrement(int column) throws SQLException { 227 Column col = cursor.getColumn(column); 228 return cursor.getColumn(column).isAutoIncrement(); 229 } 230 231 239 public boolean isCaseSensitive(int column) throws SQLException { 240 return getType(column).isCaseSensitive(); 241 } 242 243 251 public boolean isCurrency(int column) throws SQLException { 252 return getType(column).isCurrency(); 253 } 254 255 263 public boolean isDefinitelyWritable(int column) throws SQLException { 264 return cursor.isWritable(column); 265 } 266 267 274 public int isNullable(int column) throws SQLException { 275 return cursor.getColumn(column).getNullable(); 276 } 277 278 285 public boolean isReadOnly(int column) throws SQLException { 286 return !cursor.isWritable(column); 287 } 288 289 297 public boolean isSearchable(int column) throws SQLException { 298 return true; 299 } 300 301 309 public boolean isSigned(int column) throws SQLException { 310 return getType(column).isSigned(); 311 } 312 313 320 public boolean isWritable(int column) throws SQLException { 321 return cursor.isWritable(column); 322 } 323 324 private Type getType(int column) throws SQLException { 325 Type t = cursor.getColumn(column).getType(); 326 return t; 327 } 328 329 } 330 | Popular Tags |