Package org.apache.derby.iapi.types
Class CollatorSQLVarchar
java.lang.Object
org.apache.derby.iapi.types.DataType
org.apache.derby.iapi.types.SQLChar
org.apache.derby.iapi.types.SQLVarchar
org.apache.derby.iapi.types.CollatorSQLVarchar
- All Implemented Interfaces:
Externalizable
,Serializable
,Comparable
,Formatable
,Storable
,StreamStorable
,TypedFormat
,CollationElementsInterface
,ConcatableDataValue
,DataValueDescriptor
,Orderable
,StringDataValue
,VariableSizeDataValue
CollatorSQLVarchar class differs from SQLVarchar based on how the 2 classes
use different collations to collate their data. SQLVarchar uses Derby's
default collation which is UCS_BASIC. Whereas, this class uses the
RuleBasedCollator object that was passed to it in it's constructor and that
RuleBasedCollator object decides the collation.
In Derby 10.3, this class will be passed a RuleBasedCollator which is based
on the database's territory. In future releases of Derby, this class can be
used to do other kinds of collations like case-insensitive collation etc by
just passing an appropriate RuleBasedCollator object for that kind of
collation.
-
Field Summary
FieldsFields inherited from class org.apache.derby.iapi.types.SQLChar
_clobValue, arg_passer, CHAR_HEADER_GENERATOR, RETURN_SPACE_THRESHOLD, stream
Fields inherited from interface org.apache.derby.iapi.types.DataValueDescriptor
UNKNOWN_LOGICAL_LENGTH
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.StringDataValue
BOTH, COLLATION_DERIVATION_EXPLICIT, COLLATION_DERIVATION_IMPLICIT, COLLATION_DERIVATION_NONE, COLLATION_TYPE_TERRITORY_BASED, COLLATION_TYPE_TERRITORY_BASED_IDENTICAL, COLLATION_TYPE_TERRITORY_BASED_PRIMARY, COLLATION_TYPE_TERRITORY_BASED_SECONDARY, COLLATION_TYPE_TERRITORY_BASED_TERTIARY, COLLATION_TYPE_UCS_BASIC, LEADING, TRAILING
Fields inherited from interface org.apache.derby.iapi.types.VariableSizeDataValue
IGNORE_PRECISION
-
Constructor Summary
ConstructorsConstructorDescriptionCollatorSQLVarchar
(String val, RuleBasedCollator collatorForCharacterDatatypes) Create SQL VARCHAR value initially set to value that performs collation according to collatorForCharacterDatatypesCollatorSQLVarchar
(RuleBasedCollator collatorForCharacterDatatypes) Create SQL VARCHAR value initially set to NULL that performs collation according to collatorForCharacterDatatypes -
Method Summary
Modifier and TypeMethodDescriptioncloneValue
(boolean forceMaterialization) Clone this DataValueDescriptor.protected RuleBasedCollator
Get the RuleBasedCollator for this instance of CollatorSQLVarchar.Get a new null value of the same type as this data value.protected StringDataValue
Get a SQLVarchar for a built-in string function.getValue
(RuleBasedCollator collatorForComparison) We do not anticipate this method on collation sensitive DVD to be ever called in Derby 10.3 In future, when Derby will start supporting SQL standard COLLATE clause, this method might get called on the collation sensitive DVDs.int
hashCode()
Return a hash code that is consistent withstringCompare(SQLChar, SQLChar)
.boolean
Check if this instance represents a value that has a single collation element.like
(DataValueDescriptor pattern) This method implements the like function for char (with no escape value).like
(DataValueDescriptor pattern, DataValueDescriptor escape) This method implements the like function for char with an escape value.private void
setCollator
(RuleBasedCollator collatorForCharacterDatatypes) Set the RuleBasedCollator for this instance of CollatorSQLVarchar.protected int
stringCompare
(SQLChar char1, SQLChar char2) Compare two SQLChars.Methods inherited from class org.apache.derby.iapi.types.SQLVarchar
getTypeFormatId, getTypeName, growBy, normalize, normalize, typePrecedence
Methods inherited from class org.apache.derby.iapi.types.SQLChar
ansiTrim, charLength, cloneHolder, compare, compare, concatenate, copyState, equals, estimateMemoryUsage, getBoolean, getByte, getCharArray, getCollationKey, getDate, getDate, getDouble, getFloat, getInt, getLength, getLocaleFinder, getLong, getObject, getRawDataAndZeroIt, getShort, getStream, getStreamHeaderGenerator, getStreamWithDescriptor, getString, getTime, getTime, getTimestamp, getTimestamp, getTraceString, greaterOrEquals, greaterThan, hashCodeForCollation, hasNonBlankChars, isNull, lessOrEquals, lessThan, loadStream, locate, lower, notEquals, readExternal, readExternal, readExternalClobFromArray, readExternalFromArray, restoreToNull, returnStream, setBigDecimal, setFrom, setInto, setLocaleFinder, setObjectForCast, setStream, setStreamHeaderFormat, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValueFromResultSet, setWidth, stringCompare, stringCompare, substring, throwStreamingIOException, toString, typeToBigDecimal, upper, writeClobUTF, writeExternal, zeroRawData
Methods inherited from class org.apache.derby.iapi.types.DataType
checkHostVariable, coalesce, compare, compare, compareTo, dataTypeConversion, equals, flip, genericSetObject, getBytes, getTypeName, hasStream, in, invalidFormat, isNotNull, isNullOp, outOfRange, recycle, setInto, setObject, setToNull, setValue, setValue, setValue, setValue, setValue, setValue, throwLangSetMismatch, throwLangSetMismatch
-
Field Details
-
holderForCollationSensitiveInfo
-
-
Constructor Details
-
CollatorSQLVarchar
CollatorSQLVarchar(RuleBasedCollator collatorForCharacterDatatypes) Create SQL VARCHAR value initially set to NULL that performs collation according to collatorForCharacterDatatypes -
CollatorSQLVarchar
CollatorSQLVarchar(String val, RuleBasedCollator collatorForCharacterDatatypes) Create SQL VARCHAR value initially set to value that performs collation according to collatorForCharacterDatatypes
-
-
Method Details
-
setCollator
Set the RuleBasedCollator for this instance of CollatorSQLVarchar. It will be used to do the collation. -
getCollatorForCollation
Get the RuleBasedCollator for this instance of CollatorSQLVarchar. It will be used to do the collation.- Overrides:
getCollatorForCollation
in classSQLChar
- Returns:
- The Collator object which should be used for collation operation on this object
- Throws:
StandardException
-
hasSingleCollationElement
Description copied from interface:CollationElementsInterface
Check if this instance represents a value that has a single collation element.- Specified by:
hasSingleCollationElement
in interfaceCollationElementsInterface
- Returns:
true
if the value has exactly one collation element, orfalse
otherwise- Throws:
StandardException
- if an error occurs when accessing the value
-
cloneValue
Description copied from interface:DataValueDescriptor
Clone this DataValueDescriptor. Results in a new object that has the same value as this but can be modified independently.Even though the objects can be modified independently regardless of the value of
forceMaterialization
, both the clone and the original may be dependent on the store state ifforceMaterialization
is set tofalse
. An example is if you need to access the value you just read usingcloneValue
after the current transaction has ended, or after the source result set has been closed.- Specified by:
cloneValue
in interfaceDataValueDescriptor
- Overrides:
cloneValue
in classSQLVarchar
- Parameters:
forceMaterialization
- any streams representing the data value will be materialized iftrue
, the data value will be kept as a stream if possible iffalse
- Returns:
- A clone of the
DataValueDescriptor
with the same initial value as this. - See Also:
-
getNewNull
Description copied from interface:DataValueDescriptor
Get a new null value of the same type as this data value.- Specified by:
getNewNull
in interfaceDataValueDescriptor
- Overrides:
getNewNull
in classSQLVarchar
- See Also:
-
getNewVarchar
Description copied from class:SQLChar
Get a SQLVarchar for a built-in string function.- Overrides:
getNewVarchar
in classSQLChar
- Returns:
- a SQLVarchar.
- Throws:
StandardException
- Thrown on error
-
getValue
We do not anticipate this method on collation sensitive DVD to be ever called in Derby 10.3 In future, when Derby will start supporting SQL standard COLLATE clause, this method might get called on the collation sensitive DVDs.- Specified by:
getValue
in interfaceStringDataValue
- Overrides:
getValue
in classSQLVarchar
- See Also:
-
stringCompare
Description copied from class:SQLChar
Compare two SQLChars.- Overrides:
stringCompare
in classSQLChar
- Throws:
StandardException
- Thrown on error- See Also:
-
hashCode
public int hashCode()Return a hash code that is consistent withstringCompare(SQLChar, SQLChar)
. -
like
This method implements the like function for char (with no escape value). The difference in this method and the same method in superclass is that here we use special Collator object to do the comparison rather than using the Collator object associated with the default jvm locale.- Specified by:
like
in interfaceStringDataValue
- Overrides:
like
in classSQLChar
- Parameters:
pattern
- The pattern to use- Returns:
- A SQL boolean value telling whether the first operand is like the second operand
- Throws:
StandardException
- Thrown on error
-
like
public BooleanDataValue like(DataValueDescriptor pattern, DataValueDescriptor escape) throws StandardException This method implements the like function for char with an escape value.- Specified by:
like
in interfaceStringDataValue
- Overrides:
like
in classSQLChar
- Parameters:
pattern
- The pattern to useescape
- the escape character- Returns:
- A SQL boolean value telling whether the first operand is like the second operand
- Throws:
StandardException
- Thrown on error
-