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.DataValueFactory; 30 import org.apache.derby.iapi.types.TypeId; 31 32 import org.apache.derby.iapi.sql.compile.TypeCompiler; 33 34 import org.apache.derby.iapi.services.sanity.SanityManager; 35 import org.apache.derby.iapi.services.compiler.LocalField; 36 import org.apache.derby.iapi.services.compiler.MethodBuilder; 37 38 import org.apache.derby.iapi.reference.ClassName; 39 40 public class UserDefinedTypeCompiler extends BaseTypeCompiler 41 { 42 43 44 57 public boolean comparable(TypeId otherType, 58 boolean forEquals, 59 ClassFactory cf) 60 { 61 if (forEquals) 62 return true; 63 64 try { 65 Class thisClass = cf.getClassInspector().getClass( 66 getTypeId().getCorrespondingJavaTypeName()); 67 68 return java.lang.Comparable .class.isAssignableFrom(thisClass); 69 70 } catch (ClassNotFoundException cnfe) { 71 return false; 72 } 73 } 74 75 88 public boolean convertible(TypeId otherType, boolean forDataTypeFunction) 89 { 90 95 return true; 96 } 97 98 99 public boolean compatible(TypeId otherType) 100 { 101 return convertible(otherType, false); 102 } 103 104 116 public boolean storable(TypeId otherType, ClassFactory cf) 117 { 118 return cf.getClassInspector().assignableTo( 119 otherType.getCorrespondingJavaTypeName(), 120 getTypeId().getCorrespondingJavaTypeName()); 121 } 122 123 124 public String interfaceName() 125 { 126 return ClassName.UserDataValue; 127 } 128 129 132 133 public String getCorrespondingPrimitiveTypeName() 134 { 135 return getTypeId().getCorrespondingJavaTypeName(); 136 } 137 138 141 public int getCastToCharWidth(DataTypeDescriptor dts) 142 { 143 return -1; 145 } 146 147 protected String nullMethodName() 148 { 149 return "getNullObject"; 150 } 151 152 public void generateDataValue(MethodBuilder mb, 153 LocalField field) 154 { 155 mb.upCast("java.lang.Object"); 157 158 super.generateDataValue(mb, field); 159 } 160 161 162 163 } 164 | Popular Tags |