1 21 22 package org.apache.derby.impl.sql.catalog; 23 24 import java.sql.Types ; 25 26 import org.apache.derby.iapi.sql.dictionary.SystemColumn; 27 import org.apache.derby.iapi.error.StandardException; 28 import org.apache.derby.iapi.types.DataTypeDescriptor; 29 import org.apache.derby.iapi.types.DataValueDescriptor; 30 import org.apache.derby.iapi.types.DataValueFactory; 31 import org.apache.derby.iapi.types.TypeId; 32 33 40 41 class SystemColumnImpl implements SystemColumn 42 { 43 private final String name; 44 45 48 private final DataTypeDescriptor type; 49 50 60 static SystemColumn getColumn(String name, int jdbcTypeId, 61 boolean nullability) { 62 return new SystemColumnImpl(name, DataTypeDescriptor 63 .getBuiltInDataTypeDescriptor(jdbcTypeId, nullability)); 64 } 65 66 76 static SystemColumn getColumn(String name, int jdbcTypeId, 77 boolean nullability,int maxLength) { 78 return new SystemColumnImpl(name, DataTypeDescriptor 79 .getBuiltInDataTypeDescriptor(jdbcTypeId, nullability, maxLength)); 80 } 81 82 92 static SystemColumn getIdentifierColumn(String name, boolean nullability) { 93 return new SystemColumnImpl(name, DataTypeDescriptor 94 .getBuiltInDataTypeDescriptor(Types.VARCHAR, nullability, 128)); 95 } 96 97 107 static SystemColumn getUUIDColumn(String name, boolean nullability) { 108 return new SystemColumnImpl(name, DataTypeDescriptor 109 .getBuiltInDataTypeDescriptor(Types.CHAR, nullability, 36)); 110 } 111 112 120 static SystemColumn getIndicatorColumn(String name) { 121 return new SystemColumnImpl(name, DataTypeDescriptor 122 .getBuiltInDataTypeDescriptor(Types.CHAR, false, 1)); 123 } 124 125 135 static SystemColumn getJavaColumn(String name, String javaClassName, 136 boolean nullability) { 137 138 TypeId typeId = TypeId.getUserDefinedTypeId(javaClassName, false); 139 140 DataTypeDescriptor dtd = new DataTypeDescriptor(typeId, nullability); 141 return new SystemColumnImpl(name, dtd); 142 } 143 144 147 private SystemColumnImpl(String name, DataTypeDescriptor type) { 148 this.name = name; 149 this.type = type; 150 } 151 152 166 SystemColumnImpl( String name, 167 int id, 168 boolean nullability, 169 String dataType, 170 boolean builtInType, 171 int maxLength ) 172 { 173 this.name = name; 174 175 TypeId typeId; 176 177 if (builtInType) 178 { 179 typeId = TypeId.getBuiltInTypeId(dataType); 180 } 181 else 182 { 183 184 typeId = TypeId.getUserDefinedTypeId(dataType, false); 185 } 186 187 this.type = new DataTypeDescriptor( 188 typeId, 189 0, 190 0, 191 nullability, 192 maxLength 193 ); 194 } 195 SystemColumnImpl( String name, 196 int id, 197 int ignoreP, 198 int ignoreS, 199 boolean nullability, 200 String dataType, 201 boolean builtInType, 202 int maxLength ) 203 { 204 this(name, id, nullability, dataType, builtInType, maxLength); 205 } 206 207 215 SystemColumnImpl( String name, 216 int id, 217 boolean nullability) 218 { 219 this(name, id, nullability, "VARCHAR", true, 128); 220 } 221 222 227 public String getName() 228 { 229 return name; 230 } 231 232 235 public DataTypeDescriptor getType() { 236 return type; 237 } 238 } 239 240 | Popular Tags |