1 21 22 package org.apache.derby.impl.sql.compile; 23 24 import org.apache.derby.iapi.sql.compile.C_NodeTypes; 25 26 import org.apache.derby.iapi.error.StandardException; 27 28 import org.apache.derby.iapi.sql.dictionary.DataDictionary; 29 30 import org.apache.derby.iapi.types.TypeId; 31 import org.apache.derby.iapi.types.DataTypeDescriptor; 32 33 import org.apache.derby.iapi.types.StringDataValue; 34 35 import org.apache.derby.iapi.reference.SQLState; 36 import org.apache.derby.iapi.reference.ClassName; 37 38 import java.sql.Types ; 39 40 import java.util.Vector ; 41 42 47 48 public class SimpleStringOperatorNode extends UnaryOperatorNode 49 { 50 56 57 public void init(Object operand, Object methodName) 58 { 59 super.init(operand, methodName, methodName); 60 } 61 62 73 74 public ValueNode bindExpression( 75 FromList fromList, SubqueryList subqueryList, 76 Vector aggregateVector) 77 throws StandardException 78 { 79 TypeId operandType; 80 81 super.bindExpression(fromList, subqueryList, 82 aggregateVector); 83 84 88 operandType = operand.getTypeId(); 89 90 switch (operandType.getJDBCTypeId()) 91 { 92 case Types.CHAR: 93 case Types.VARCHAR: 94 case Types.LONGVARCHAR: 95 case Types.CLOB: 96 break; 97 case org.apache.derby.iapi.reference.JDBC20Translation.SQL_TYPES_JAVA_OBJECT: 98 case Types.OTHER: 99 { 100 throw StandardException.newException(SQLState.LANG_UNARY_FUNCTION_BAD_TYPE, 101 methodName, 102 operandType.getSQLTypeName()); 103 } 104 105 default: 106 operand = (ValueNode) 107 getNodeFactory().getNode( 108 C_NodeTypes.CAST_NODE, 109 operand, 110 DataTypeDescriptor.getBuiltInDataTypeDescriptor(Types.VARCHAR, true, 111 operand.getTypeCompiler(). 112 getCastToCharWidth( 113 operand.getTypeServices())), 114 getContextManager()); 115 ((CastNode) operand).bindCastNodeOnly(); 116 operandType = operand.getTypeId(); 117 } 118 119 122 123 setType(new DataTypeDescriptor(operandType, 124 operand.getTypeServices().isNullable(), 125 operand.getTypeCompiler(). 126 getCastToCharWidth(operand.getTypeServices()) 127 ) 128 ); 129 130 return this; 131 } 132 133 138 139 void bindParameter() 140 throws StandardException 141 { 142 147 148 operand.setType(DataTypeDescriptor.getBuiltInDataTypeDescriptor(Types.VARCHAR)); 149 } 150 151 155 public String getReceiverInterfaceName() { 156 return ClassName.StringDataValue; 157 } 158 159 162 public boolean requiresTypeFromContext() 163 { 164 return false; 167 } 168 } 169 | Popular Tags |