Class Collator
- All Implemented Interfaces:
Freezable<Collator>
,Cloneable
,Comparator<Object>
- Direct Known Subclasses:
RuleBasedCollator
Collator performs locale-sensitive string comparison. A concrete subclass, RuleBasedCollator, allows customization of the collation ordering by the use of rule sets.
A Collator is thread-safe only when frozen. See isFrozen()
and Freezable
.
Following the Unicode Consortium's specifications for the Unicode Collation Algorithm (UCA), there are 5 different levels of strength used in comparisons:
- PRIMARY strength: Typically, this is used to denote differences between base characters (for example, "a" < "b"). It is the strongest difference. For example, dictionaries are divided into different sections by base character.
- SECONDARY strength: Accents in the characters are considered secondary differences (for example, "as" < "às" < "at"). Other differences between letters can also be considered secondary differences, depending on the language. A secondary difference is ignored when there is a primary difference anywhere in the strings.
- TERTIARY strength: Upper and lower case differences in characters are distinguished at tertiary strength (for example, "ao" < "Ao" < "aò"). In addition, a variant of a letter differs from the base form on the tertiary strength (such as "A" and "Ⓐ"). Another example is the difference between large and small Kana. A tertiary difference is ignored when there is a primary or secondary difference anywhere in the strings.
- QUATERNARY strength: When punctuation is ignored (see Ignoring Punctuations in the User Guide) at PRIMARY to TERTIARY strength, an additional strength level can be used to distinguish words with and without punctuation (for example, "ab" < "a-b" < "aB"). This difference is ignored when there is a PRIMARY, SECONDARY or TERTIARY difference. The QUATERNARY strength should only be used if ignoring punctuation is required.
- IDENTICAL strength: When all other strengths are equal, the IDENTICAL strength is used as a tiebreaker. The Unicode code point values of the NFD form of each string are compared, just in case there is no difference. For example, Hebrew cantillation marks are only distinguished at this strength. This strength should be used sparingly, as only code point value differences between two strings is an extremely rare occurrence. Using this strength substantially decreases the performance for both comparison and collation key generation APIs. This strength also increases the size of the collation key.
For more information about the collation service see the User Guide.
Examples of use
// Get the Collator for US English and set its strength to PRIMARY Collator usCollator = Collator.getInstance(Locale.US); usCollator.setStrength(Collator.PRIMARY); if (usCollator.compare("abc", "ABC") == 0) { System.out.println("Strings are equivalent"); } The following example shows how to compare two strings using the Collator for the default locale. // Compare two strings in the default locale Collator myCollator = Collator.getInstance(); myCollator.setDecomposition(NO_DECOMPOSITION); if (myCollator.compare("à\u0325", "a\u0325̀") != 0) { System.out.println("à\u0325 is not equals to a\u0325̀ without decomposition"); myCollator.setDecomposition(CANONICAL_DECOMPOSITION); if (myCollator.compare("à\u0325", "a\u0325̀") != 0) { System.out.println("Error: à\u0325 should be equals to a\u0325̀ with decomposition"); } else { System.out.println("à\u0325 is equals to a\u0325̀ with decomposition"); } } else { System.out.println("Error: à\u0325 should be not equals to a\u0325̀ without decomposition"); }
- Author:
- Syn Wee Quek
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
A factory used with registerFactory to register multiple collators and provide display names for them.static interface
Reordering codes for non-script groups that can be reordered under collation. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Decomposition mode value.static final int
This is for backwards compatibility with Java APIs only.static final int
Smallest Collator strength value.static final int
Decomposition mode value.static final int
Strongest collator strength value.static final int
Fourth level collator strength value.static final int
Second level collator strength value.static final int
Third level collator strength value. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Collator()
Empty default constructor to make javadocs happy -
Method Summary
Modifier and TypeMethodDescriptionclone()
Clones the collator.Provides for the clone operation.int
Compares the source Object to the target Object.abstract int
Compares the source text String to the target text String according to this Collator's rules, strength and decomposition mode.protected int
doCompare
(CharSequence left, CharSequence right) Deprecated.This API is ICU internal only.boolean
Compares the equality of two Collator objects.boolean
Compares the equality of two text Strings using this Collator's rules, strength and decomposition mode.freeze()
Freezes the collator.static Locale[]
Returns the set of locales, as Locale objects, for which collators are installed.static final ULocale[]
Returns the set of locales, as ULocale objects, for which collators are installed.abstract CollationKey
getCollationKey
(String source) Transforms the String into a CollationKey suitable for efficient repeated comparison.int
Returns the decomposition mode of this Collator.static String
getDisplayName
(ULocale objectLocale) Returns the name of the collator for the objectLocale, localized for the defaultDISPLAY
locale.static String
getDisplayName
(ULocale objectLocale, ULocale displayLocale) Returns the name of the collator for the objectLocale, localized for the displayLocale.static String
getDisplayName
(Locale objectLocale) Returns the name of the collator for the objectLocale, localized for the defaultDISPLAY
locale.static String
getDisplayName
(Locale objectLocale, Locale displayLocale) Returns the name of the collator for the objectLocale, localized for the displayLocale.static int[]
getEquivalentReorderCodes
(int reorderCode) Retrieves all the reorder codes that are grouped with the given reorder code.static final ULocale
getFunctionalEquivalent
(String keyword, ULocale locID) Returns the functionally equivalent locale for the given requested locale, with respect to given keyword, for the collation service.static final ULocale
getFunctionalEquivalent
(String keyword, ULocale locID, boolean[] isAvailable) Returns the functionally equivalent locale for the given requested locale, with respect to given keyword, for the collation service.static final Collator
Returns the Collator for the current default locale.static final Collator
getInstance
(ULocale locale) Returns the Collator for the desired locale.static final Collator
getInstance
(Locale locale) Returns the Collator for the desired locale.static final String[]
Returns an array of all possible keywords that are relevant to collation.static final String[]
getKeywordValues
(String keyword) Given a keyword, returns an array of all values for that keyword that are currently in use.static final String[]
getKeywordValuesForLocale
(String key, ULocale locale, boolean commonlyUsed) Given a key and a locale, returns an array of string values in a preferred order that would make a difference.getLocale
(ULocale.Type type) Returns the locale that was used to create this object, or null.int
Returns the maximum reordering group whose characters are affected by the alternate handling behavior.abstract RawCollationKey
getRawCollationKey
(String source, RawCollationKey key) Returns the simpler form of a CollationKey for the String source following the rules of this Collator and stores the result into the user provided argument key.int[]
Retrieves the reordering codes for this collator.int
Returns this Collator's strength attribute.Returns a UnicodeSet that contains all the characters and sequences tailored in this collator.abstract VersionInfo
Returns the UCA version of this collator object.abstract int
Gets the variable top value of a Collator.abstract VersionInfo
Returns the version of this collator object.int
hashCode()
Generates a hash code for this Collator object.boolean
isFrozen()
Determines whether the object has been frozen or not.static final Object
registerFactory
(Collator.CollatorFactory factory) Registers a collator factory.static final Object
registerInstance
(Collator collator, ULocale locale) Registers a collator as the default collator for the provided locale.void
setDecomposition
(int decomposition) Sets the decomposition mode of this Collator.setMaxVariable
(int group) Sets the variable top to the top of the specified reordering group.void
setReorderCodes
(int... order) Sets the reordering codes for this collator.void
setStrength
(int newStrength) Sets this Collator's strength attribute.setStrength2
(int newStrength) Deprecated.This API is ICU internal only.abstract void
setVariableTop
(int varTop) Deprecated.ICU 53 Call setMaxVariable() instead.abstract int
setVariableTop
(String varTop) Deprecated.ICU 53 CallsetMaxVariable(int)
instead.static final boolean
unregister
(Object registryKey) Unregisters a collator previously registered using registerInstance.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
-
Field Details
-
PRIMARY
public static final int PRIMARYStrongest collator strength value. Typically used to denote differences between base characters. See class documentation for more explanation.- See Also:
-
SECONDARY
public static final int SECONDARYSecond level collator strength value. Accents in the characters are considered secondary differences. Other differences between letters can also be considered secondary differences, depending on the language. See class documentation for more explanation.- See Also:
-
TERTIARY
public static final int TERTIARYThird level collator strength value. Upper and lower case differences in characters are distinguished at this strength level. In addition, a variant of a letter differs from the base form on the tertiary level. See class documentation for more explanation.- See Also:
-
QUATERNARY
public static final int QUATERNARYFourth level collator strength value. When punctuation is ignored (see Ignoring Punctuation in the User Guide) at PRIMARY to TERTIARY strength, an additional strength level can be used to distinguish words with and without punctuation. See class documentation for more explanation.- See Also:
-
IDENTICAL
public static final int IDENTICALSmallest Collator strength value. When all other strengths are equal, the IDENTICAL strength is used as a tiebreaker. The Unicode code point values of the NFD form of each string are compared, just in case there is no difference. See class documentation for more explanation.Note this value is different from JDK's
- See Also:
-
FULL_DECOMPOSITION
public static final int FULL_DECOMPOSITIONThis is for backwards compatibility with Java APIs only. It should not be used, IDENTICAL should be used instead. ICU's collation does not support Java's FULL_DECOMPOSITION mode.- See Also:
-
NO_DECOMPOSITION
public static final int NO_DECOMPOSITIONDecomposition mode value. With NO_DECOMPOSITION set, Strings will not be decomposed for collation. This is the default decomposition setting unless otherwise specified by the locale used to create the Collator.Note this value is different from the JDK's.
- See Also:
-
CANONICAL_DECOMPOSITION
public static final int CANONICAL_DECOMPOSITIONDecomposition mode value. With CANONICAL_DECOMPOSITION set, characters that are canonical variants according to the Unicode standard will be decomposed for collation.CANONICAL_DECOMPOSITION corresponds to Normalization Form D as described in Unicode Technical Report #15.
- See Also:
-
-
Constructor Details
-
Collator
protected Collator()Empty default constructor to make javadocs happy
-
-
Method Details
-
equals
Compares the equality of two Collator objects. Collator objects are equal if they have the same collation (sorting & searching) behavior.The base class checks for null and for equal types. Subclasses should override.
- Specified by:
equals
in interfaceComparator<Object>
- Overrides:
equals
in classObject
- Parameters:
obj
- the Collator to compare to.- Returns:
- true if this Collator has exactly the same collation behavior as obj, false otherwise.
-
hashCode
public int hashCode()Generates a hash code for this Collator object.The implementation exists just for consistency with
equals(Object)
implementation in this class and does not generate a useful hash code. Subclasses should override this implementation. -
setStrength
public void setStrength(int newStrength) Sets this Collator's strength attribute. The strength attribute determines the minimum level of difference considered significant during comparison.The base class method does nothing. Subclasses should override it if appropriate.
See the Collator class description for an example of use.
- Parameters:
newStrength
- the new strength value.- Throws:
IllegalArgumentException
- if the new strength value is not valid.- See Also:
-
setStrength2
Deprecated.This API is ICU internal only.- Returns:
- this, for chaining
-
setDecomposition
public void setDecomposition(int decomposition) Sets the decomposition mode of this Collator. Setting this decomposition attribute with CANONICAL_DECOMPOSITION allows the Collator to handle un-normalized text properly, producing the same results as if the text were normalized. If NO_DECOMPOSITION is set, it is the user's responsibility to insure that all text is already in the appropriate form before a comparison or before getting a CollationKey. Adjusting decomposition mode allows the user to select between faster and more complete collation behavior.Since a great many of the world's languages do not require text normalization, most locales set NO_DECOMPOSITION as the default decomposition mode.
The base class method does nothing. Subclasses should override it if appropriate.
See getDecomposition for a description of decomposition mode.
- Parameters:
decomposition
- the new decomposition mode- Throws:
IllegalArgumentException
- If the given value is not a valid decomposition mode.- See Also:
-
setReorderCodes
public void setReorderCodes(int... order) Sets the reordering codes for this collator. Collation reordering allows scripts and some other groups of characters to be moved relative to each other. This reordering is done on top of the DUCET/CLDR standard collation order. Reordering can specify groups to be placed at the start and/or the end of the collation order. These groups are specified using UScript codes andCollator.ReorderCodes
entries.By default, reordering codes specified for the start of the order are placed in the order given after several special non-script blocks. These special groups of characters are space, punctuation, symbol, currency, and digit. These special groups are represented with
Collator.ReorderCodes
entries. Script groups can be intermingled with these special non-script groups if those special groups are explicitly specified in the reordering.The special code
OTHERS
stands for any script that is not explicitly mentioned in the list of reordering codes given. Anything that is after OTHERS will go at the very end of the reordering in the order given.The special reorder code
DEFAULT
will reset the reordering for this collator to the default for this collator. The default reordering may be the DUCET/CLDR order or may be a reordering that was specified when this collator was created from resource data or from rules. The DEFAULT code must be the sole code supplied when it is used. If not, then anIllegalArgumentException
will be thrown.The special reorder code
NONE
will remove any reordering for this collator. The result of setting no reordering will be to have the DUCET/CLDR ordering used. The NONE code must be the sole code supplied when it is used.- Parameters:
order
- the reordering codes to apply to this collator; if this is null or an empty array then this clears any existing reordering- See Also:
-
getInstance
Returns the Collator for the current default locale. The default locale is determined by java.util.Locale.getDefault().- Returns:
- the Collator for the default locale (for example, en_US) if it is created successfully. Otherwise if there is no Collator associated with the current locale, the root collator will be returned.
- See Also:
-
clone
Clones the collator.- Overrides:
clone
in classObject
- Returns:
- a clone of this collator.
- Throws:
CloneNotSupportedException
-
getInstance
Returns the Collator for the desired locale.For some languages, multiple collation types are available; for example, "de@collation=phonebook". Starting with ICU 54, collation attributes can be specified via locale keywords as well, in the old locale extension syntax ("el@colCaseFirst=upper") or in language tag syntax ("el-u-kf-upper"). See User Guide: Collation API.
- Parameters:
locale
- the desired locale.- Returns:
- Collator for the desired locale if it is created successfully. Otherwise if there is no Collator associated with the current locale, the root collator will be returned.
- See Also:
-
getInstance
Returns the Collator for the desired locale.For some languages, multiple collation types are available; for example, "de-u-co-phonebk". Starting with ICU 54, collation attributes can be specified via locale keywords as well, in the old locale extension syntax ("el@colCaseFirst=upper", only with
ULocale
) or in language tag syntax ("el-u-kf-upper"). See User Guide: Collation API.- Parameters:
locale
- the desired locale.- Returns:
- Collator for the desired locale if it is created successfully. Otherwise if there is no Collator associated with the current locale, the root collator will be returned.
- See Also:
-
registerInstance
Registers a collator as the default collator for the provided locale. The collator should not be modified after it is registered.Because ICU may choose to cache Collator objects internally, this must be called at application startup, prior to any calls to Collator.getInstance to avoid undefined behavior.
- Parameters:
collator
- the collator to registerlocale
- the locale for which this is the default collator- Returns:
- an object that can be used to unregister the registered collator.
-
registerFactory
Registers a collator factory.Because ICU may choose to cache Collator objects internally, this must be called at application startup, prior to any calls to Collator.getInstance to avoid undefined behavior.
- Parameters:
factory
- the factory to register- Returns:
- an object that can be used to unregister the registered factory.
-
unregister
Unregisters a collator previously registered using registerInstance.- Parameters:
registryKey
- the object previously returned by registerInstance.- Returns:
- true if the collator was successfully unregistered.
-
getAvailableLocales
Returns the set of locales, as Locale objects, for which collators are installed. Note that Locale objects do not support RFC 3066.- Returns:
- the list of locales in which collators are installed. This list includes any that have been registered, in addition to those that are installed with ICU4J.
-
getAvailableULocales
Returns the set of locales, as ULocale objects, for which collators are installed. ULocale objects support RFC 3066.- Returns:
- the list of locales in which collators are installed. This list includes any that have been registered, in addition to those that are installed with ICU4J.
-
getKeywords
Returns an array of all possible keywords that are relevant to collation. At this point, the only recognized keyword for this service is "collation".- Returns:
- an array of valid collation keywords.
- See Also:
-
getKeywordValues
Given a keyword, returns an array of all values for that keyword that are currently in use.- Parameters:
keyword
- one of the keywords returned by getKeywords.- See Also:
-
getKeywordValuesForLocale
public static final String[] getKeywordValuesForLocale(String key, ULocale locale, boolean commonlyUsed) Given a key and a locale, returns an array of string values in a preferred order that would make a difference. These are all and only those values where the open (creation) of the service with the locale formed from the input locale plus input keyword and that value has different behavior than creation with the input locale alone.- Parameters:
key
- one of the keys supported by this service. For now, only "collation" is supported.locale
- the localecommonlyUsed
- if set to true it will return only commonly used values with the given locale in preferred order. Otherwise, it will return all the available values for the locale.- Returns:
- an array of string values for the given key and the locale.
-
getFunctionalEquivalent
public static final ULocale getFunctionalEquivalent(String keyword, ULocale locID, boolean[] isAvailable) Returns the functionally equivalent locale for the given requested locale, with respect to given keyword, for the collation service. If two locales return the same result, then collators instantiated for these locales will behave equivalently. The converse is not always true; two collators may in fact be equivalent, but return different results, due to internal details. The return result has no other meaning than that stated above, and implies nothing as to the relationship between the two locales. This is intended for use by applications who wish to cache collators, or otherwise reuse collators when possible. The functional equivalent may change over time. For more information, please see the Locales and Services section of the ICU User Guide.- Parameters:
keyword
- a particular keyword as enumerated by getKeywords.locID
- The requested localeisAvailable
- If non-null, isAvailable[0] will receive and output boolean that indicates whether the requested locale was 'available' to the collation service. If non-null, isAvailable must have length >= 1.- Returns:
- the locale
-
getFunctionalEquivalent
Returns the functionally equivalent locale for the given requested locale, with respect to given keyword, for the collation service.- Parameters:
keyword
- a particular keyword as enumerated by getKeywords.locID
- The requested locale- Returns:
- the locale
- See Also:
-
getDisplayName
Returns the name of the collator for the objectLocale, localized for the displayLocale.- Parameters:
objectLocale
- the locale of the collatordisplayLocale
- the locale for the collator's display name- Returns:
- the display name
-
getDisplayName
Returns the name of the collator for the objectLocale, localized for the displayLocale.- Parameters:
objectLocale
- the locale of the collatordisplayLocale
- the locale for the collator's display name- Returns:
- the display name
-
getDisplayName
Returns the name of the collator for the objectLocale, localized for the defaultDISPLAY
locale.- Parameters:
objectLocale
- the locale of the collator- Returns:
- the display name
- See Also:
-
getDisplayName
Returns the name of the collator for the objectLocale, localized for the defaultDISPLAY
locale.- Parameters:
objectLocale
- the locale of the collator- Returns:
- the display name
- See Also:
-
getStrength
public int getStrength()Returns this Collator's strength attribute. The strength attribute determines the minimum level of difference considered significant. This can return QUATERNARY strength, which is not supported by the JDK version.See the Collator class description for more details.
The base class method always returns
TERTIARY
. Subclasses should override it if appropriate.- Returns:
- this Collator's current strength attribute.
- See Also:
-
getDecomposition
public int getDecomposition()Returns the decomposition mode of this Collator. The decomposition mode determines how Unicode composed characters are handled.See the Collator class description for more details.
The base class method always returns
NO_DECOMPOSITION
. Subclasses should override it if appropriate.- Returns:
- the decomposition mode
- See Also:
-
equals
Compares the equality of two text Strings using this Collator's rules, strength and decomposition mode. Convenience method.- Parameters:
source
- the source string to be compared.target
- the target string to be compared.- Returns:
- true if the strings are equal according to the collation rules, otherwise false.
- Throws:
NullPointerException
- thrown if either arguments is null.- See Also:
-
getTailoredSet
Returns a UnicodeSet that contains all the characters and sequences tailored in this collator.- Returns:
- a pointer to a UnicodeSet object containing all the code points and sequences that may sort differently than in the root collator.
-
compare
Compares the source text String to the target text String according to this Collator's rules, strength and decomposition mode. 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.- 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.
- Throws:
NullPointerException
- thrown if either argument is null.- See Also:
-
compare
Compares the source Object to the target Object.- Specified by:
compare
in interfaceComparator<Object>
- Parameters:
source
- the source Object.target
- the target Object.- 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.
- Throws:
ClassCastException
- thrown if either arguments cannot be cast to CharSequence.
-
doCompare
Deprecated.This API is ICU internal only.Compares two CharSequences. The base class just calls compare(left.toString(), right.toString()). Subclasses should instead implement this method and have the String API call this method. -
getCollationKey
Transforms the String into a CollationKey suitable for efficient repeated comparison. The resulting key depends on the collator's rules, strength and decomposition mode.
Note that collation keys are often less efficient than simply doing comparison. For more details, see the ICU User Guide.
See the CollationKey class documentation for more information.
- Parameters:
source
- the string to be transformed into a CollationKey.- 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.
- See Also:
-
getRawCollationKey
Returns the simpler form of a CollationKey for the String source following the rules of this Collator and stores the result into the user provided argument key. If key has a internal byte array of length that's too small for the result, the internal byte array will be grown to the exact required size.Note that collation keys are often less efficient than simply doing comparison. For more details, see the ICU User Guide.
- Parameters:
source
- the text String to be transformed into a RawCollationKey- Returns:
- If key is null, a new instance of RawCollationKey will be created and returned, otherwise the user provided key will be returned.
- See Also:
-
setMaxVariable
Sets the variable top to the top of the specified reordering group. The variable top determines the highest-sorting character which is affected by the alternate handling behavior. If that attribute is set to UCOL_NON_IGNORABLE, then the variable top has no effect.The base class implementation throws an UnsupportedOperationException.
- Parameters:
group
- one of Collator.ReorderCodes.SPACE, Collator.ReorderCodes.PUNCTUATION, Collator.ReorderCodes.SYMBOL, Collator.ReorderCodes.CURRENCY; or Collator.ReorderCodes.DEFAULT to restore the default max variable group- Returns:
- this
- See Also:
-
getMaxVariable
public int getMaxVariable()Returns the maximum reordering group whose characters are affected by the alternate handling behavior.The base class implementation returns Collator.ReorderCodes.PUNCTUATION.
- Returns:
- the maximum variable reordering group.
- See Also:
-
setVariableTop
Deprecated.ICU 53 CallsetMaxVariable(int)
instead.Sets the variable top to the primary weight of the specified string.Beginning with ICU 53, the variable top is pinned to the top of one of the supported reordering groups, and it must not be beyond the last of those groups. See
setMaxVariable(int)
.- Parameters:
varTop
- one or more (if contraction) characters to which the variable top should be set- Returns:
- variable top primary weight
- Throws:
IllegalArgumentException
- is thrown if varTop argument is not a valid variable top element. A variable top element is invalid when- it is a contraction that does not exist in the Collation order
- the variable top is beyond the last reordering group supported by setMaxVariable()
- when the varTop argument is null or zero in length.
- See Also:
-
getVariableTop
public abstract int getVariableTop()Gets the variable top value of a Collator.- Returns:
- the variable top primary weight
- See Also:
-
setVariableTop
Deprecated.ICU 53 Call setMaxVariable() instead.Sets the variable top to the specified primary weight.Beginning with ICU 53, the variable top is pinned to the top of one of the supported reordering groups, and it must not be beyond the last of those groups. See
setMaxVariable(int)
.- Parameters:
varTop
- primary weight, as returned by setVariableTop or getVariableTop- See Also:
-
getVersion
Returns the version of this collator object.- Returns:
- the version object associated with this collator
-
getUCAVersion
Returns the UCA version of this collator object.- Returns:
- the version object associated with this collator
-
getReorderCodes
public int[] getReorderCodes()Retrieves the reordering codes for this collator. These reordering codes are a combination of UScript codes and ReorderCodes.- Returns:
- a copy of the reordering codes for this collator; if none are set then returns an empty array
- See Also:
-
getEquivalentReorderCodes
public static int[] getEquivalentReorderCodes(int reorderCode) Retrieves all the reorder codes that are grouped with the given reorder code. Some reorder codes are grouped and must reorder together. Beginning with ICU 55, scripts only reorder together if they are primary-equal, for example Hiragana and Katakana.- Parameters:
reorderCode
- The reorder code to determine equivalence for.- Returns:
- the set of all reorder codes in the same group as the given reorder code.
- See Also:
-
isFrozen
public boolean isFrozen()Determines whether the object has been frozen or not.An unfrozen Collator is mutable and not thread-safe. A frozen Collator is immutable and thread-safe.
-
freeze
Freezes the collator. -
cloneAsThawed
Provides for the clone operation. Any clone is initially unfrozen.- Specified by:
cloneAsThawed
in interfaceFreezable<Collator>
-
getLocale
Returns the locale that was used to create this object, or null. This may may differ from the locale requested at the time of this object's creation. For example, if an object is created for locale en_US_CALIFORNIA, the actual data may be drawn from en (the actual locale), and en_US may be the most specific locale that exists (the valid locale).Note: This method will be implemented in ICU 3.0; ICU 2.8 contains a partial preview implementation. The actual locale is returned correctly, but the valid locale is not, in most cases.
The base class method always returns
ULocale.ROOT
. Subclasses should override it if appropriate.- Parameters:
type
- type of information requested, eitherULocale.VALID_LOCALE
orULocale.ACTUAL_LOCALE
.- Returns:
- the information specified by type, or null if this object was not constructed from locale data.
- See Also:
-