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.services.i18n.LocaleFinder; 37 38 import java.util.Locale ; 39 import java.util.Calendar ; 40 41 import java.sql.Date ; 42 import java.sql.Time ; 43 import java.sql.Timestamp ; 44 45 59 public class SQLNationalLongvarchar 60 extends SQLLongvarchar 61 { 62 69 70 public String getTypeName() 71 { 72 return TypeId.NATIONAL_LONGVARCHAR_NAME; 73 } 74 75 78 79 80 public DataValueDescriptor getClone() 81 { 82 try 83 { 84 88 return new SQLNationalLongvarchar(getString(), getLocaleFinder()); 89 } 90 catch (StandardException se) 91 { 92 if (SanityManager.DEBUG) 93 SanityManager.THROWASSERT("Unexpected exception " + se); 94 return null; 95 } 96 } 97 98 102 public DataValueDescriptor getNewNull() 103 { 104 108 SQLNationalLongvarchar result = new SQLNationalLongvarchar(); 109 result.setLocaleFinder(getLocaleFinder()); 110 return result; 111 } 112 113 116 117 122 public int getTypeFormatId() { 123 return StoredFormatIds.SQL_NATIONAL_LONGVARCHAR_ID; 124 } 125 126 129 130 public SQLNationalLongvarchar() 131 { 132 } 133 134 public SQLNationalLongvarchar(String val, LocaleFinder localeFinder) 135 { 136 super(val); 137 setLocaleFinder(localeFinder); 138 } 139 140 144 public Date getDate( Calendar cal) throws StandardException 145 { 146 return nationalGetDate(cal); 147 } 148 149 153 public Time getTime( Calendar cal) throws StandardException 154 { 155 return nationalGetTime(cal); 156 } 157 158 162 public Timestamp getTimestamp( Calendar cal) throws StandardException 163 { 164 return nationalGetTimestamp(cal); 165 } 166 167 170 171 172 public int typePrecedence() 173 { 174 return TypeId.NATIONAL_LONGVARCHAR_PRECEDENCE; 175 } 176 177 184 protected int stringCompare(SQLChar char1, SQLChar char2) 185 throws StandardException 186 { 187 return char1.stringCollatorCompare(char2); 188 } 189 190 196 protected StringDataValue getNewVarchar() 197 { 198 return new SQLNationalVarchar(); 199 } 200 201 204 protected boolean isNationalString() 205 { 206 return true; 207 } 208 209 214 public void setValue(Date theValue, Calendar cal) throws StandardException 215 { 216 setValue(getDateFormat(cal).format(theValue)); 217 } 218 219 224 public void setValue(Time theValue, Calendar cal) throws StandardException 225 { 226 setValue(getTimeFormat(cal).format(theValue)); 227 } 228 229 234 public void setValue(Timestamp theValue, Calendar cal) throws StandardException 235 { 236 setValue(getTimestampFormat(cal).format(theValue)); 237 } 238 protected void setFrom(DataValueDescriptor theValue) throws StandardException { 239 240 setValue(((DataType) theValue).getNationalString(getLocaleFinder())); 241 } 242 243 244 public int hashCode() 245 { 246 return nationalHashCode(); 247 } 248 249 public void normalize( 250 DataTypeDescriptor desiredType, 251 DataValueDescriptor source) 252 throws StandardException 253 { 254 normalize(desiredType, ((DataType) source).getNationalString(getLocaleFinder())); 255 } 256 } 257 | Popular Tags |