1 21 22 package org.apache.derby.impl.sql; 23 24 import org.apache.derby.iapi.sql.ResultColumnDescriptor; 25 import org.apache.derby.iapi.types.DataTypeDescriptor; 26 27 import org.apache.derby.iapi.services.sanity.SanityManager; 28 29 import org.apache.derby.iapi.services.io.StoredFormatIds; 30 import org.apache.derby.iapi.services.io.FormatIdUtil; 31 import org.apache.derby.iapi.services.io.Formatable; 32 33 import org.apache.derby.iapi.services.io.FormatableHashtable; 34 import org.apache.derby.iapi.services.io.FormatableIntHolder; 35 36 import java.io.ObjectOutput ; 37 import java.io.ObjectInput ; 38 import java.io.IOException ; 39 46 public final class GenericColumnDescriptor 47 implements ResultColumnDescriptor, Formatable 48 { 49 50 63 64 private String name; 65 private String schemaName; 66 private String tableName; 67 private int columnPos; 68 private DataTypeDescriptor type; 69 private boolean isAutoincrement; 70 private boolean updatableByCursor; 71 72 75 public GenericColumnDescriptor() 76 { 77 } 78 79 public GenericColumnDescriptor(String name, DataTypeDescriptor type) { 80 this.name = name; 81 this.type = type; 82 } 83 84 93 public GenericColumnDescriptor(ResultColumnDescriptor rcd) 94 { 95 name = rcd.getName(); 96 tableName = rcd.getSourceTableName(); 97 schemaName = rcd.getSourceSchemaName(); 98 columnPos = rcd.getColumnPosition(); 99 type = rcd.getType(); 100 isAutoincrement = rcd.isAutoincrement(); 101 updatableByCursor = rcd.updatableByCursor(); 102 } 103 104 111 public DataTypeDescriptor getType() 112 { 113 return type; 114 } 115 116 121 public String getName() 122 { 123 return name; 124 } 125 126 136 public String getSourceSchemaName() 137 { 138 return schemaName; 139 } 140 141 151 public String getSourceTableName() 152 { 153 return tableName; 154 } 155 156 163 public int getColumnPosition() 164 { 165 return columnPos; 166 } 167 168 public boolean isAutoincrement() 169 { 170 return isAutoincrement; 171 } 172 173 public boolean updatableByCursor() 174 { 175 return updatableByCursor; 176 } 177 178 190 public void writeExternal(ObjectOutput out) throws IOException 191 { 192 FormatableHashtable fh = new FormatableHashtable(); 193 fh.put("name", name); 194 fh.put("tableName", tableName); 195 fh.put("schemaName", schemaName); 196 fh.putInt("columnPos", columnPos); 197 fh.put("type", type); 198 fh.putBoolean("isAutoincrement", isAutoincrement); 199 fh.putBoolean("updatableByCursor", updatableByCursor); 200 out.writeObject(fh); 201 return; 202 } 203 204 public void djdrcd() {} 205 213 public void readExternal(ObjectInput in) 214 throws IOException , ClassNotFoundException 215 { 216 FormatableHashtable fh = (FormatableHashtable)in.readObject(); 217 name = (String )fh.get("name"); 218 tableName = (String )fh.get("tableName"); 219 schemaName = (String )fh.get("schemaName"); 220 columnPos = fh.getInt("columnPos"); 221 type = (DataTypeDescriptor)fh.get("type"); 222 isAutoincrement = fh.getBoolean("isAutoincrement"); 223 updatableByCursor = fh.getBoolean("updatableByCursor"); 224 } 225 226 231 public int getTypeFormatId() { return StoredFormatIds.GENERIC_COLUMN_DESCRIPTOR_V02_ID; } 232 233 public String toString() 234 { 235 if (SanityManager.DEBUG) 236 { 237 return "GenericColumnDescriptor\n\tname: "+name+ 238 "\n\tTable: "+schemaName+"."+tableName+ 239 "\n\tcolumnPos: "+columnPos+ 240 "\n\tType: "+type; 241 } 242 else 243 { 244 return ""; 245 } 246 } 247 } 248 | Popular Tags |