1 21 22 package org.apache.derby.impl.sql.compile; 23 24 import org.apache.derby.iapi.services.loader.ClassFactory; 25 26 import org.apache.derby.iapi.services.sanity.SanityManager; 27 28 import org.apache.derby.iapi.services.io.StoredFormatIds; 29 30 import org.apache.derby.iapi.error.StandardException; 31 32 import org.apache.derby.iapi.types.BitDataValue; 33 import org.apache.derby.iapi.types.DataValueFactory; 34 import org.apache.derby.iapi.types.TypeId; 35 36 import org.apache.derby.iapi.types.DataTypeDescriptor; 37 38 import org.apache.derby.iapi.sql.compile.TypeCompiler; 39 40 import org.apache.derby.iapi.reference.ClassName; 41 42 import java.sql.Types ; 43 import org.apache.derby.iapi.reference.JDBC20Translation; 44 45 50 51 public class LOBTypeCompiler extends BaseTypeCompiler 52 { 53 59 60 public boolean comparable(TypeId otherType, 61 boolean forEquals, 62 ClassFactory cf) 63 { 64 return false; 65 } 66 67 68 69 74 public boolean convertible(TypeId otherType, 75 boolean forDataTypeFunction) 76 { 77 78 return (otherType.isBlobTypeId()); 79 } 80 81 86 public boolean compatible(TypeId otherType) 87 { 88 return convertible(otherType,false); 89 } 90 91 97 98 public boolean storable(TypeId otherType, ClassFactory cf) 99 { 100 102 return (otherType.isBlobTypeId()); 103 } 104 105 106 public String interfaceName() 107 { 108 return ClassName.BitDataValue; 109 } 110 111 114 115 public String getCorrespondingPrimitiveTypeName() { 116 int formatId = getStoredFormatIdFromTypeId(); 117 switch (formatId) { 118 case StoredFormatIds.BLOB_TYPE_ID: return "java.sql.Blob"; 119 default: 120 if (SanityManager.DEBUG) 121 SanityManager.THROWASSERT("unexpected formatId in getCorrespondingPrimitiveTypeName() - " + formatId); 122 return null; 123 } 124 } 125 126 129 public int getCastToCharWidth(DataTypeDescriptor dts) 130 { 131 return dts.getMaximumWidth(); 132 } 133 134 protected String nullMethodName() { 135 int formatId = getStoredFormatIdFromTypeId(); 136 switch (formatId) { 137 case StoredFormatIds.BLOB_TYPE_ID: return "getNullBlob"; 138 default: 139 if (SanityManager.DEBUG) 140 SanityManager.THROWASSERT("unexpected formatId in nullMethodName() - " + formatId); 141 return null; 142 } 143 } 144 145 protected String dataValueMethodName() 146 { 147 int formatId = getStoredFormatIdFromTypeId(); 148 switch (formatId) { 149 case StoredFormatIds.BLOB_TYPE_ID: return "getBlobDataValue"; 150 default: 151 if (SanityManager.DEBUG) 152 SanityManager.THROWASSERT("unexpected formatId in dataValueMethodName() - " + formatId); 153 return null; 154 } 155 } 156 } 157 | Popular Tags |