1 21 22 package org.apache.derby.iapi.types; 23 24 import org.apache.derby.iapi.types.DataTypeDescriptor; 25 import org.apache.derby.iapi.types.DataValueDescriptor; 26 import org.apache.derby.iapi.types.TypeId; 27 import org.apache.derby.iapi.types.StringDataValue; 28 import org.apache.derby.iapi.reference.SQLState; 29 import org.apache.derby.iapi.error.StandardException; 30 31 import org.apache.derby.iapi.services.io.FormatIdUtil; 32 import org.apache.derby.iapi.services.io.StoredFormatIds; 33 34 import org.apache.derby.iapi.services.sanity.SanityManager; 35 36 import org.apache.derby.iapi.util.StringUtil; 37 38 52 public class SQLLongvarchar 53 extends SQLVarchar 54 { 55 62 63 public String getTypeName() 64 { 65 return TypeId.LONGVARCHAR_NAME; 66 } 67 68 71 72 73 public DataValueDescriptor getClone() 74 { 75 try 76 { 77 return new SQLLongvarchar(getString()); 78 } 79 catch (StandardException se) 80 { 81 if (SanityManager.DEBUG) 82 SanityManager.THROWASSERT("Unexpected exception " + se); 83 return null; 84 } 85 } 86 87 91 public DataValueDescriptor getNewNull() 92 { 93 return new SQLLongvarchar(); 94 } 95 96 99 100 105 public int getTypeFormatId() { 106 return StoredFormatIds.SQL_LONGVARCHAR_ID; 107 } 108 109 112 113 public SQLLongvarchar() 114 { 115 } 116 117 public SQLLongvarchar(String val) 118 { 119 super(val); 120 } 121 122 protected void normalize(DataTypeDescriptor desiredType, String sourceValue) 123 throws StandardException 124 { 125 if (sourceValue.length() > desiredType.getMaximumWidth()) 127 throw StandardException.newException(SQLState.LANG_STRING_TRUNCATION, getTypeName(), StringUtil.formatForPrint(sourceValue), String.valueOf(desiredType.getMaximumWidth())); 128 129 setValue(sourceValue); 130 } 131 132 137 public StringDataValue concatenate( 138 StringDataValue leftOperand, 139 StringDataValue rightOperand, 140 StringDataValue result) 141 throws StandardException 142 { 143 super.concatenate(leftOperand, rightOperand, result); 144 145 149 if ((result.getString() != null) && (result.getString().length() > TypeId.LONGVARCHAR_MAXWIDTH)) 151 throw StandardException.newException(SQLState.LANG_CONCAT_STRING_OVERFLOW, "CONCAT", String.valueOf(TypeId.LONGVARCHAR_MAXWIDTH)); 152 153 return result; 154 } 155 156 159 160 161 public int typePrecedence() 162 { 163 return TypeId.LONGVARCHAR_PRECEDENCE; 164 } 165 } 166 | Popular Tags |