Package com.tangosol.util
Class CacheCollator
java.lang.Object
java.text.Collator
com.tangosol.util.CacheCollator
- All Implemented Interfaces:
Serializable
,Cloneable
,Comparator<Object>
Implements a collator which caches its keys.
- Version:
- 1.00, 10/01/98
- Author:
- Cameron Purdy
- See Also:
-
Field Summary
Fields inherited from class java.text.Collator
CANONICAL_DECOMPOSITION, FULL_DECOMPOSITION, IDENTICAL, NO_DECOMPOSITION, PRIMARY, SECONDARY, TERTIARY
-
Constructor Summary
ConstructorDescriptionCacheCollator
(Collator collator) Construct this collator to cache the results of another collator. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Clone the caching collator.int
Compares the source string to the target string according to the collation rules for this Collator.boolean
Compares the equality of two Collators.protected Map
getCache()
getCollationKey
(String source) Transforms the String into a series of bits that can be compared bitwise to other CollationKeys.int
Get the decomposition mode of this Collator.int
Returns this Collator's strength property.int
hashCode()
Generates the hash code for this Collator.void
setDecomposition
(int decomposition) Set the decomposition mode of this Collator.void
setStrength
(int newStrength) Sets this Collator's strength property.Methods inherited from class java.text.Collator
compare, equals, getAvailableLocales, getInstance, getInstance
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Constructor Details
-
CacheCollator
Construct this collator to cache the results of another collator.- Parameters:
collator
- the collator to delegate to
-
-
Method Details
-
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 classCollator
- 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 classCollator
- 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 classCollator
- 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 classCollator
- Parameters:
decomposition
- the new decomposition mode- Throws:
UnsupportedOperationException
- always thrown
-
compare
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 classCollator
- 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
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 classCollator
- 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
Clone the caching collator. -
equals
Compares the equality of two Collators.- Specified by:
equals
in interfaceComparator<Object>
- Overrides:
equals
in classCollator
- 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. -
getCache
- Returns:
- the internal cache map
-