Class CacheCollator

    • Constructor Detail

      • CacheCollator

        public CacheCollator​(Collator collator)
        Construct this collator to cache the results of another collator.
        Parameters:
        collator - the collator to delegate to
    • Method Detail

      • getStrength

        public int getStrength()
        Returns this Collator's strength property. The strength property determines the minimum level of difference considered significant during comparison.
        Overrides:
        getStrength in class Collator
        Returns:
        this Collator's current strength property.
      • setStrength

        public void setStrength​(int newStrength)
        Sets this Collator's strength property. The strength property determines the minimum level of difference considered significant during comparison.
        Overrides:
        setStrength in class Collator
        Parameters:
        newStrength - the new strength value.
        Throws:
        UnsupportedOperationException - always thrown
      • getDecomposition

        public int getDecomposition()
        Get the decomposition mode of this Collator. Decomposition mode determines how Unicode composed characters are handled. Adjusting decomposition mode allows the user to select between faster and more complete collation behavior.
        Overrides:
        getDecomposition in class Collator
        Returns:
        the decomposition mode
      • setDecomposition

        public void setDecomposition​(int decomposition)
        Set the decomposition mode of this Collator. See getDecomposition for a description of decomposition mode.
        Overrides:
        setDecomposition in class Collator
        Parameters:
        decomposition - the new decomposition mode
        Throws:
        UnsupportedOperationException - always thrown
      • compare

        public int compare​(String source,
                           String target)
        Compares the source string to the target string according to the collation rules for this Collator. Returns an integer less than, equal to or greater than zero depending on whether the source String is less than, equal to or greater than the target string. See the Collator class description for an example of use.

        For a one time comparison, this method has the best performance. If a given String will be involved in multiple comparisons, CollationKey.compareTo has the best performance. See the Collator class description for an example using CollationKeys.

        Specified by:
        compare in class Collator
        Parameters:
        source - the source string.
        target - the target string.
        Returns:
        Returns an integer value. Value is less than zero if source is less than target, value is zero if source and target are equal, value is greater than zero if source is greater than target.
      • getCollationKey

        public CollationKey getCollationKey​(String source)
        Transforms the String into a series of bits that can be compared bitwise to other CollationKeys. CollationKeys provide better performance than Collator.compare when Strings are involved in multiple comparisons. See the Collator class description for an example using CollationKeys.
        Specified by:
        getCollationKey in class Collator
        Parameters:
        source - the string to be transformed into a collation key.
        Returns:
        the CollationKey for the given String based on this Collator's collation rules. If the source String is null, a null CollationKey is returned.
      • clone

        public Object clone()
        Clone the caching collator.
        Overrides:
        clone in class Collator
        Returns:
        a clone of this object
      • equals

        public boolean equals​(Object that)
        Compares the equality of two Collators.
        Specified by:
        equals in interface Comparator<Object>
        Overrides:
        equals in class Collator
        Parameters:
        that - the Collator to be compared with this.
        Returns:
        true if this Collator is the same as that Collator; false otherwise.
      • hashCode

        public int hashCode()
        Generates the hash code for this Collator.
        Specified by:
        hashCode in class Collator
        Returns:
        the hashcode of the delegatee collator
      • getCache

        protected Map getCache()
        Returns:
        the internal cache map