1 24 25 package org.objectweb.cjdbc.driver; 26 27 import java.io.IOException ; 28 import java.io.Serializable ; 29 30 import org.objectweb.cjdbc.common.stream.CJDBCInputStream; 31 import org.objectweb.cjdbc.common.stream.CJDBCOutputStream; 32 33 46 public class Field implements Serializable 47 { 48 61 private String tableName; 62 private String fieldName; 63 private int columnDisplaySize; 64 private int sqlType; 65 private String typeName; 66 private String columnClassName; 67 private boolean isAutoIncrement; 68 private boolean isCaseSensitive; 69 private boolean isCurrency; 70 private int isNullable; 71 private boolean isReadOnly; 72 private boolean isWritable; 73 private boolean isDefinitelyWritable; 74 private boolean isSearchable; 75 private boolean isSigned; 76 private int precision; 77 private int scale; 78 79 89 public Field(String table, String name, int columnDisplaySize, int sqlType, 90 String typeName, String columnClassName) 91 { 92 this(table, name, columnDisplaySize, sqlType, typeName, columnClassName, 93 false, true, false, ResultSetMetaData.columnNullable, true, false, 94 false, false, false, 0, 0); 95 } 96 97 118 public Field(String table, String name, int columnDisplaySize, int sqlType, 119 String typeName, String columnClassName, boolean isAutoIncrement, 120 boolean isCaseSensitive, boolean isCurrency, int isNullable, 121 boolean isReadOnly, boolean isWritable, boolean isDefinitelyWritable, 122 boolean isSearchable, boolean isSigned, int precision, int scale) 123 { 124 if (table == null) 125 this.tableName = null; 126 else 127 this.tableName = new String (table); 128 this.fieldName = new String (name); 129 this.columnDisplaySize = columnDisplaySize; 130 this.sqlType = sqlType; 131 this.typeName = typeName; 132 this.columnClassName = columnClassName; 133 this.isAutoIncrement = isAutoIncrement; 134 this.isCaseSensitive = isCaseSensitive; 135 this.isCurrency = isCurrency; 136 this.isNullable = isNullable; 137 this.isReadOnly = isReadOnly; 138 this.isWritable = isWritable; 139 this.isDefinitelyWritable = isDefinitelyWritable; 140 this.isSearchable = isSearchable; 141 this.isSigned = isSigned; 142 this.precision = precision; 143 this.scale = scale; 144 } 145 146 153 public Field(CJDBCInputStream in) throws IOException 154 { 155 if (in.readBoolean()) 156 this.tableName = in.readUTF(); 157 else 158 this.tableName = null; 159 160 this.fieldName = in.readUTF(); 161 this.columnDisplaySize = in.readInt(); 162 this.sqlType = in.readInt(); 163 this.typeName = in.readUTF(); 164 this.columnClassName = in.readUTF(); 165 this.isAutoIncrement = in.readBoolean(); 166 this.isCaseSensitive = in.readBoolean(); 167 this.isCurrency = in.readBoolean(); 168 this.isNullable = in.readInt(); 169 this.isReadOnly = in.readBoolean(); 170 this.isWritable = in.readBoolean(); 171 this.isDefinitelyWritable = in.readBoolean(); 172 this.isSearchable = in.readBoolean(); 173 this.isSigned = in.readBoolean(); 174 this.precision = in.readInt(); 175 this.scale = in.readInt(); 176 } 177 178 186 public void sendToStream(CJDBCOutputStream out) throws IOException 187 { 188 if (null == this.tableName) 189 out.writeBoolean(false); 190 else 191 { 192 out.writeBoolean(true); 193 out.writeUTF(this.tableName); 194 } 195 196 out.writeUTF(this.fieldName); 197 out.writeInt(this.columnDisplaySize); 198 out.writeInt(this.sqlType); 199 out.writeUTF(this.typeName); 200 out.writeUTF(this.columnClassName); 201 out.writeBoolean(this.isAutoIncrement); 202 out.writeBoolean(this.isCaseSensitive); 203 out.writeBoolean(this.isCurrency); 204 out.writeInt(this.isNullable); 205 out.writeBoolean(this.isReadOnly); 206 out.writeBoolean(this.isWritable); 207 out.writeBoolean(this.isDefinitelyWritable); 208 out.writeBoolean(this.isSearchable); 209 out.writeBoolean(this.isSigned); 210 out.writeInt(this.precision); 211 out.writeInt(this.scale); 212 213 } 214 215 220 public String getTableName() 221 { 222 return tableName; 223 } 224 225 231 public String getFieldName() 232 { 233 return fieldName; 234 } 235 236 241 public String getFullName() 242 { 243 return tableName + "." + fieldName; 244 } 245 246 252 public void setFieldName(String name) 253 { 254 fieldName = name; 255 } 256 257 263 public String toString() 264 { 265 return getFullName(); 266 } 267 268 274 public int getSqlType() 275 { 276 return sqlType; 277 } 278 279 285 public String getTypeName() 286 { 287 return typeName; 288 } 289 290 295 public String getColumnClassName() 296 { 297 return columnClassName; 298 } 299 300 303 public int getColumnDisplaySize() 304 { 305 return columnDisplaySize; 306 } 307 308 311 public boolean isAutoIncrement() 312 { 313 return isAutoIncrement; 314 } 315 316 319 public boolean isCaseSensitive() 320 { 321 return isCaseSensitive; 322 } 323 324 327 public boolean isCurrency() 328 { 329 return isCurrency; 330 } 331 332 335 public boolean isDefinitelyWritable() 336 { 337 return isDefinitelyWritable; 338 } 339 340 343 public int isNullable() 344 { 345 return isNullable; 346 } 347 348 351 public boolean isReadOnly() 352 { 353 return isReadOnly; 354 } 355 356 359 public boolean isWritable() 360 { 361 return isWritable; 362 } 363 364 367 public boolean isSearchable() 368 { 369 return isSearchable; 370 } 371 372 375 public boolean isSigned() 376 { 377 return isSigned; 378 } 379 380 383 public int getPrecision() 384 { 385 return precision; 386 } 387 388 391 public int getScale() 392 { 393 return scale; 394 } 395 396 } | Popular Tags |