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.error.StandardException; 27 28 import org.apache.derby.iapi.types.DataTypeDescriptor; 29 import org.apache.derby.iapi.types.DataTypeDescriptor; 30 import org.apache.derby.iapi.types.DateTimeDataValue; 31 import org.apache.derby.iapi.types.DataValueFactory; 32 import org.apache.derby.iapi.types.TypeId; 33 34 import org.apache.derby.iapi.sql.compile.TypeCompiler; 35 36 import org.apache.derby.iapi.services.sanity.SanityManager; 37 38 import java.sql.Types ; 39 import org.apache.derby.iapi.reference.ClassName; 40 41 public class TimeTypeCompiler extends BaseTypeCompiler 42 { 43 44 45 55 public boolean comparable(TypeId otherType, 56 boolean forEquals, 57 ClassFactory cf) 58 { 59 int otherJDBCTypeId = otherType.getJDBCTypeId(); 60 61 if (otherType.isLongConcatableTypeId()) 63 return false; 64 65 if (otherJDBCTypeId == Types.TIME || otherType.isStringTypeId()) 66 return true; 67 68 TypeCompiler otherTC = getTypeCompiler(otherType); 69 70 71 if (otherType.userType()) 72 { 73 return otherTC.comparable(getTypeId(), forEquals, cf); 74 } 75 76 return false; 77 } 78 79 88 public boolean convertible(TypeId otherType, 89 boolean forDataTypeFunction) 90 { 91 92 if (otherType.isStringTypeId() && 93 (!otherType.isLOBTypeId()) && 94 !otherType.isLongVarcharTypeId()) 95 { 96 return true; 97 } 98 99 100 103 return (getStoredFormatIdFromTypeId() == 104 otherType.getTypeFormatId()); 105 106 } 107 108 109 public boolean compatible(TypeId otherType) 110 { 111 return convertible(otherType,false); 112 } 113 114 126 public boolean storable(TypeId otherType, ClassFactory cf) 127 { 128 int otherJDBCTypeId = otherType.getJDBCTypeId(); 129 130 if (otherJDBCTypeId == Types.TIME || 131 (otherJDBCTypeId == Types.CHAR) || 132 (otherJDBCTypeId == Types.VARCHAR)) 133 { 134 return true; 135 } 136 137 return cf.getClassInspector().assignableTo( 138 otherType.getCorrespondingJavaTypeName(), 139 "java.sql.Time"); 140 } 141 142 143 public String interfaceName() 144 { 145 return ClassName.DateTimeDataValue; 146 } 147 148 151 152 public String getCorrespondingPrimitiveTypeName() 153 { 154 return "java.sql.Time"; 155 } 156 157 160 public int getCastToCharWidth(DataTypeDescriptor dts) 161 { 162 return 8; 163 } 164 165 public double estimatedMemoryUsage(DataTypeDescriptor dtd) 166 { 167 return 12.0; 168 } 169 170 protected String nullMethodName() 171 { 172 return "getNullTime"; 173 } 174 } 175 | Popular Tags |