1 21 22 package org.apache.derby.impl.sql.compile; 23 24 import org.apache.derby.iapi.reference.SQLState; 25 26 import org.apache.derby.iapi.services.loader.ClassFactory; 27 import org.apache.derby.iapi.services.sanity.SanityManager; 28 import org.apache.derby.iapi.services.io.StoredFormatIds; 29 30 import org.apache.derby.iapi.error.StandardException; 31 import org.apache.derby.iapi.sql.conn.ConnectionUtil; 32 33 import org.apache.derby.iapi.types.BitDataValue; 34 import org.apache.derby.iapi.types.DataValueFactory; 35 import org.apache.derby.iapi.types.TypeId; 36 37 import org.apache.derby.iapi.types.DataTypeDescriptor; 38 39 import org.apache.derby.iapi.sql.compile.TypeCompiler; 40 41 import org.apache.derby.iapi.reference.ClassName; 42 43 import java.sql.Types ; 44 import org.apache.derby.iapi.reference.JDBC20Translation; 45 46 51 52 public class CLOBTypeCompiler extends BaseTypeCompiler 53 { 54 60 61 public boolean comparable(TypeId otherType, 62 boolean forEquals, 63 ClassFactory cf) 64 { 65 return false; 66 } 67 68 69 74 public boolean convertible(TypeId otherType, 75 boolean forDataTypeFunction) 76 { 77 return (otherType.isStringTypeId()) ; 79 80 } 81 82 87 public boolean compatible(TypeId otherType) 88 { 89 return convertible(otherType,false); 90 } 91 92 98 99 public boolean storable(TypeId otherType, ClassFactory cf) 100 { 101 return (otherType.isStringTypeId()) ; 105 } 106 107 108 public String interfaceName() 109 { 110 return ClassName.StringDataValue; 111 } 112 113 116 117 public String getCorrespondingPrimitiveTypeName() { 118 int formatId = getStoredFormatIdFromTypeId(); 119 switch (formatId) { 120 case StoredFormatIds.CLOB_TYPE_ID: return "java.sql.Clob"; 121 case StoredFormatIds.NCLOB_TYPE_ID: return "java.sql.Clob"; 122 default: 123 if (SanityManager.DEBUG) 124 SanityManager.THROWASSERT("unexpected formatId in getCorrespondingPrimitiveTypeName() - " + formatId); 125 return null; 126 } 127 } 128 129 public String getMatchingNationalCharTypeName() 130 { 131 return TypeId.NCLOB_NAME; 132 } 133 134 137 public int getCastToCharWidth(DataTypeDescriptor dts) 138 { 139 return dts.getMaximumWidth(); 140 } 141 142 protected String nullMethodName() { 143 int formatId = getStoredFormatIdFromTypeId(); 144 switch (formatId) { 145 case StoredFormatIds.CLOB_TYPE_ID: return "getNullClob"; 146 case StoredFormatIds.NCLOB_TYPE_ID: return "getNullNClob"; 147 default: 148 if (SanityManager.DEBUG) 149 SanityManager.THROWASSERT("unexpected formatId in nullMethodName() - " + formatId); 150 return null; 151 } 152 } 153 154 protected String dataValueMethodName() 155 { 156 int formatId = getStoredFormatIdFromTypeId(); 157 switch (formatId) { 158 case StoredFormatIds.CLOB_TYPE_ID: return "getClobDataValue"; 159 case StoredFormatIds.NCLOB_TYPE_ID: return "getNClobDataValue"; 160 default: 161 if (SanityManager.DEBUG) 162 SanityManager.THROWASSERT("unexpected formatId in dataValueMethodName() - " + formatId); 163 return null; 164 } 165 } 166 } 167 | Popular Tags |