org.apache.derby.iapi.types
Class SQLNationalVarchar

java.lang.Object
  extended byorg.apache.derby.iapi.types.DataType
      extended byorg.apache.derby.iapi.types.SQLChar
          extended byorg.apache.derby.iapi.types.SQLVarchar
              extended byorg.apache.derby.iapi.types.SQLNationalVarchar
All Implemented Interfaces:
CloneableObject, ConcatableDataValue, DataValueDescriptor, java.io.Externalizable, Formatable, Orderable, java.io.Serializable, Storable, StreamStorable, StringDataValue, TypedFormat, VariableSizeDataValue
Direct Known Subclasses:
SQLNClob

public class SQLNationalVarchar
extends SQLVarchar

SQLNationalVarchar satisfies the DataValueDescriptor interfaces (i.e., OrderableDataType). It implements a String holder, e.g. for storing a column value; it can be specified when constructed to not allow nulls. Nullability cannot be changed after construction.

Because OrderableDataType is a subclass of DataType, SQLNationalVarchar can play a role in either a DataType/ValueRow or a OrderableDataType/KeyRow, interchangeably. SQLNationalVarchar is mostly the same as SQLVarchar, so it is implemented as a subclass of SQLVarchar. Only those methods with different behavior are implemented here.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.apache.derby.iapi.types.SQLChar
arg_passer, stream
 
Fields inherited from interface org.apache.derby.iapi.types.StringDataValue
BOTH, LEADING, TRAILING
 
Fields inherited from interface org.apache.derby.iapi.types.Orderable
ORDER_OP_EQUALS, ORDER_OP_GREATEROREQUALS, ORDER_OP_GREATERTHAN, ORDER_OP_LESSOREQUALS, ORDER_OP_LESSTHAN
 
Fields inherited from interface org.apache.derby.iapi.types.VariableSizeDataValue
IGNORE_PRECISION
 
Constructor Summary
SQLNationalVarchar()
           
SQLNationalVarchar(java.lang.String val, LocaleFinder localeFinder)
           
 
Method Summary
 DataValueDescriptor getClone()
          Shallow copy.
 java.sql.Date getDate(java.util.Calendar cal)
          Gets the value in the data value descriptor as a java.sql.Date.
 DataValueDescriptor getNewNull()
          Get a new null value of the same type as this data value.
protected  StringDataValue getNewVarchar()
          Get a SQLVarchar for a built-in string function.
 java.sql.Time getTime(java.util.Calendar cal)
          Gets the value in the data value descriptor as a java.sql.Time.
 java.sql.Timestamp getTimestamp(java.util.Calendar cal)
          Gets the value in the data value descriptor as a java.sql.Timestamp.
 int getTypeFormatId()
          Return my format identifier.
 java.lang.String getTypeName()
          Get the SQL name of the datatype
 int hashCode()
           
protected  boolean isNationalString()
          Return whether or not this is a national character datatype.
 void normalize(DataTypeDescriptor desiredType, DataValueDescriptor source)
          Normalization method - this method may be called when putting a value into a SQLVarchar, for example, when inserting into a SQLVarchar column.
protected  void setFrom(DataValueDescriptor theValue)
           
 void setValue(java.sql.Date theValue, java.util.Calendar cal)
          Set the value of this DataValueDescriptor.
 void setValue(java.sql.Time theValue, java.util.Calendar cal)
          Set the value of this DataValueDescriptor.
 void setValue(java.sql.Timestamp theValue, java.util.Calendar cal)
          Set the value of this DataValueDescriptor.
protected  int stringCompare(SQLChar char1, SQLChar char2)
          Compare two SQLChars.
 int typePrecedence()
          Each built-in type in JSQL has a precedence.
 
Methods inherited from class org.apache.derby.iapi.types.SQLVarchar
normalize
 
Methods inherited from class org.apache.derby.iapi.types.SQLChar
appendBlanks, charLength, cloneObject, compare, compare, concatenate, copyState, equals, estimateMemoryUsage, getBigDecimal, getBoolean, getByte, getCharArray, getCollationKey, getDate, getDateFormat, getDateFormat, getDouble, getFloat, getInt, getLength, getLocaleFinder, getLong, getObject, getShort, getStream, getString, getTime, getTimeFormat, getTimeFormat, getTimestamp, getTimestampFormat, getTimestampFormat, greaterOrEquals, greaterThan, hasNonBlankChars, isNull, lessOrEquals, lessThan, like, like, loadStream, locate, lower, nationalGetDate, nationalGetTime, nationalGetTimestamp, nationalHashCode, notEquals, readExternal, readExternalFromArray, restoreToNull, returnStream, setInto, setLocaleFinder, setStream, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValueFromResultSet, setWidth, stringCollatorCompare, stringCompare, stringCompare, substring, toString, trim, upper, writeExternal
 
Methods inherited from class org.apache.derby.iapi.types.DataType
checkHostVariable, coalesce, dataTypeConversion, equals, flip, genericSetObject, getBytes, getNationalString, in, invalidFormat, isNotNull, isNullOp, outOfRange, setInto, setObjectForCast, setToNull, setValue, setValue, setValue, setValue, throwLangSetMismatch, throwLangSetMismatch
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.derby.iapi.types.DataValueDescriptor
checkHostVariable, coalesce, getBytes, in, isNotNull, isNullOp, setInto, setObjectForCast, setToNull, setValue, setValue, setValue, setValue
 

Constructor Detail

SQLNationalVarchar

public SQLNationalVarchar()

SQLNationalVarchar

public SQLNationalVarchar(java.lang.String val,
                          LocaleFinder localeFinder)
Method Detail

getTypeName

public java.lang.String getTypeName()
Description copied from interface: DataValueDescriptor
Get the SQL name of the datatype

Specified by:
getTypeName in interface DataValueDescriptor
Overrides:
getTypeName in class SQLVarchar

stringCompare

protected int stringCompare(SQLChar char1,
                            SQLChar char2)
                     throws StandardException
Compare two SQLChars. This method will be overriden in the National char wrappers so that the appropriate comparison is done.

Overrides:
stringCompare in class SQLChar
Throws:
StandardException - Thrown on error

getClone

public DataValueDescriptor getClone()
Description copied from interface: DataValueDescriptor
Shallow copy.

Clone the DataValueDescriptor and copy its contents. We clone the data value wrapper (e.g. SQLDecimal) and reuse its contents (the underlying BigDecimal). The resultant DataValueDescriptor will point to the same value as the original DataValueDescriptor (unless the value is a primitive type, e.g. SQLInteger/integer).

Specified by:
getClone in interface DataValueDescriptor
Overrides:
getClone in class SQLVarchar
See Also:
DataValueDescriptor.getClone()

getNewNull

public DataValueDescriptor getNewNull()
Description copied from interface: DataValueDescriptor
Get a new null value of the same type as this data value.

Specified by:
getNewNull in interface DataValueDescriptor
Overrides:
getNewNull in class SQLVarchar
See Also:
DataValueDescriptor.getNewNull()

getTypeFormatId

public int getTypeFormatId()
Return my format identifier.

Specified by:
getTypeFormatId in interface TypedFormat
Overrides:
getTypeFormatId in class SQLVarchar
See Also:
TypedFormat.getTypeFormatId()

getDate

public java.sql.Date getDate(java.util.Calendar cal)
                      throws StandardException
Description copied from interface: DataValueDescriptor
Gets the value in the data value descriptor as a java.sql.Date. Throws an exception if the data value is not a Date.

Specified by:
getDate in interface DataValueDescriptor
Overrides:
getDate in class SQLChar
Throws:
StandardException - thrown on failure to convert
See Also:
DataValueDescriptor.getDate(java.util.Calendar)

getTime

public java.sql.Time getTime(java.util.Calendar cal)
                      throws StandardException
Description copied from interface: DataValueDescriptor
Gets the value in the data value descriptor as a java.sql.Time. Throws an exception if the data value is not a Time.

Specified by:
getTime in interface DataValueDescriptor
Overrides:
getTime in class SQLChar
Throws:
StandardException - thrown on failure to convert
See Also:
DataValueDescriptor.getTime(java.util.Calendar)

getTimestamp

public java.sql.Timestamp getTimestamp(java.util.Calendar cal)
                                throws StandardException
Description copied from interface: DataValueDescriptor
Gets the value in the data value descriptor as a java.sql.Timestamp. Throws an exception if the data value is not a Timestamp.

Specified by:
getTimestamp in interface DataValueDescriptor
Overrides:
getTimestamp in class SQLChar
Throws:
StandardException - thrown on failure to convert
See Also:
DataValueDescriptor.getTimestamp(java.util.Calendar)

typePrecedence

public int typePrecedence()
Description copied from interface: DataValueDescriptor
Each built-in type in JSQL has a precedence. This precedence determines how to do type promotion when using binary operators. For example, float has a higher precedence than int, so when adding an int to a float, the result type is float. The precedence for some types is arbitrary. For example, it doesn't matter what the precedence of the boolean type is, since it can't be mixed with other types. But the precedence for the number types is critical. The SQL standard requires that exact numeric types be promoted to approximate numeric when one operator uses both. Also, the precedence is arranged so that one will not lose precision when promoting a type.

Specified by:
typePrecedence in interface DataValueDescriptor
Overrides:
typePrecedence in class SQLVarchar

getNewVarchar

protected StringDataValue getNewVarchar()
Get a SQLVarchar for a built-in string function. (Could be either a SQLVarchar or SQLNationalVarchar.)

Overrides:
getNewVarchar in class SQLChar
Returns:
a SQLVarchar or SQLNationalVarchar.

isNationalString

protected boolean isNationalString()
Return whether or not this is a national character datatype.

Overrides:
isNationalString in class SQLChar

setValue

public void setValue(java.sql.Date theValue,
                     java.util.Calendar cal)
              throws StandardException
Description copied from interface: DataValueDescriptor
Set the value of this DataValueDescriptor.

Specified by:
setValue in interface DataValueDescriptor
Overrides:
setValue in class SQLChar
Throws:
StandardException - Thrown on error
See Also:
DataValueDescriptor.setValue(java.lang.Object)

setValue

public void setValue(java.sql.Time theValue,
                     java.util.Calendar cal)
              throws StandardException
Description copied from interface: DataValueDescriptor
Set the value of this DataValueDescriptor.

Specified by:
setValue in interface DataValueDescriptor
Overrides:
setValue in class SQLChar
Throws:
StandardException - Thrown on error
See Also:
DataValueDescriptor.setValue(java.lang.Object)

setValue

public void setValue(java.sql.Timestamp theValue,
                     java.util.Calendar cal)
              throws StandardException
Description copied from interface: DataValueDescriptor
Set the value of this DataValueDescriptor.

Specified by:
setValue in interface DataValueDescriptor
Overrides:
setValue in class SQLChar
Throws:
StandardException - Thrown on error
See Also:
DataValueDescriptor.setValue(java.lang.Object)

normalize

public void normalize(DataTypeDescriptor desiredType,
                      DataValueDescriptor source)
               throws StandardException
Description copied from class: SQLVarchar
Normalization method - this method may be called when putting a value into a SQLVarchar, for example, when inserting into a SQLVarchar column. See NormalizeResultSet in execution.

Specified by:
normalize in interface DataValueDescriptor
Overrides:
normalize in class SQLVarchar
Parameters:
desiredType - The type to normalize the source column to
source - The value to normalize
Throws:
StandardException - Thrown for null into non-nullable column, and for truncation error

setFrom

protected void setFrom(DataValueDescriptor theValue)
                throws StandardException
Overrides:
setFrom in class SQLChar
Throws:
StandardException

hashCode

public int hashCode()
Overrides:
hashCode in class SQLChar
See Also:
Object.hashCode()


Apache Derby V10.0 Engine Documentation - Copyright © 1997,2004 The Apache Software Foundation or its licensors, as applicable.