Class CollatorSQLChar

  • All Implemented Interfaces:
    java.io.Externalizable, java.io.Serializable, java.lang.Comparable, Formatable, Storable, StreamStorable, TypedFormat, CollationElementsInterface, ConcatableDataValue, DataValueDescriptor, Orderable, StringDataValue, VariableSizeDataValue

    class CollatorSQLChar
    extends SQLChar
    implements CollationElementsInterface
    CollatorSQLChar class differs from SQLChar based on how the 2 classes use different collations to collate their data. SQLChar 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.
    • Constructor Detail

      • CollatorSQLChar

        CollatorSQLChar​(java.text.RuleBasedCollator collatorForCharacterDatatypes)
        Create SQL CHAR value initially set to NULL that performs collation according to collatorForCharacterDatatypes
      • CollatorSQLChar

        CollatorSQLChar​(java.lang.String val,
                        java.text.RuleBasedCollator collatorForCharacterDatatypes)
        Create SQL CHAR value initially set to value that performs collation according to collatorForCharacterDatatypes
    • Method Detail

      • setCollator

        private void setCollator​(java.text.RuleBasedCollator collatorForCharacterDatatypes)
        Set the RuleBasedCollator for this instance of CollatorSQLChar. It will be used to do the collation.
      • getCollatorForCollation

        protected java.text.RuleBasedCollator getCollatorForCollation()
                                                               throws StandardException
        Get the RuleBasedCollator for this instance of CollatorSQLChar. It will be used to do the collation.
        Overrides:
        getCollatorForCollation in class SQLChar
        Returns:
        The Collator object which should be used for collation operation on this object
        Throws:
        StandardException
      • cloneValue

        public DataValueDescriptor cloneValue​(boolean forceMaterialization)
        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 if forceMaterialization is set to false. An example is if you need to access the value you just read using cloneValue after the current transaction has ended, or after the source result set has been closed.

        Specified by:
        cloneValue in interface DataValueDescriptor
        Overrides:
        cloneValue in class SQLChar
        Parameters:
        forceMaterialization - any streams representing the data value will be materialized if true, the data value will be kept as a stream if possible if false
        Returns:
        A clone of the DataValueDescriptor with the same initial value as this.
        See Also:
        DataValueDescriptor.cloneValue(boolean)
      • like

        public BooleanDataValue like​(DataValueDescriptor pattern)
                              throws StandardException
        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 interface StringDataValue
        Overrides:
        like in class SQLChar
        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