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 40 import java.sql.Date ; 41 import java.sql.Time ; 42 import java.sql.Timestamp ; 43 import java.util.Calendar ; 44 45 60 public class SQLNClob 61 extends SQLNationalVarchar 62 { 63 70 71 public String getTypeName() 72 { 73 return TypeId.NCLOB_NAME; 74 } 75 76 79 80 81 public DataValueDescriptor getClone() 82 { 83 try 84 { 85 89 return new SQLNClob(getString(), getLocaleFinder()); 90 } 91 catch (StandardException se) 92 { 93 if (SanityManager.DEBUG) 94 SanityManager.THROWASSERT("Unexpected exception " + se); 95 return null; 96 } 97 } 98 99 103 public DataValueDescriptor getNewNull() 104 { 105 109 SQLNClob result = new SQLNClob(); 110 result.setLocaleFinder(getLocaleFinder()); 111 return result; 112 } 113 114 117 118 123 public int getTypeFormatId() { 124 return StoredFormatIds.SQL_NCLOB_ID; 125 } 126 127 130 131 public SQLNClob() 132 { 133 } 134 135 public SQLNClob(String val, LocaleFinder localeFinder) 136 { 137 super(val, 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.NCLOB_PRECEDENCE; 175 } 176 177 185 protected int stringCompare(SQLChar char1, SQLChar char2) 186 throws StandardException 187 { 188 return char1.stringCollatorCompare(char2); 189 } 190 191 197 protected StringDataValue getNewVarchar() 198 { 199 return new SQLNationalVarchar(); 200 } 201 202 205 protected boolean isNationalString() 206 { 207 return true; 208 } 209 210 215 public void setValue(Date theValue, Calendar cal) throws StandardException 216 { 217 setValue(getDateFormat(cal).format(theValue)); 218 } 219 220 225 public void setValue(Time theValue, Calendar cal) throws StandardException 226 { 227 setValue(getTimeFormat(cal).format(theValue)); 228 } 229 230 235 public void setValue(Timestamp theValue, Calendar cal) throws StandardException 236 { 237 setValue(getTimestampFormat(cal).format(theValue)); 238 } 239 protected void setFrom(DataValueDescriptor theValue) throws StandardException { 240 241 setValue(((DataType) theValue).getNationalString(getLocaleFinder())); 242 } 243 244 245 public int hashCode() 246 { 247 return nationalHashCode(); 248 } 249 } 250 | Popular Tags |