GeezerVison is showing docs.oracle.com — Collator (Java Platform SE 8 )
Java™ Platform Standard Ed. 8
compact1, compact2, compact3
java.text
Class Collator
-
-
Constructor Summary
Constructors
| Modifier |
Constructor |
Description |
protected |
Collator() |
Default constructor.
|
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
| Modifier and Type |
Method |
Description |
Object |
clone() |
Overrides Cloneable
|
int |
compare(Object o1,
Object o2) |
Compares its two arguments for order.
|
abstract int |
compare(String source,
String target) |
Compares the source string to the target string according to the
collation rules for this Collator.
|
boolean |
equals(Object that) |
Compares the equality of two Collators.
|
boolean |
equals(String source,
String target) |
Convenience method for comparing the equality of two strings based on
this Collator's collation rules.
|
static Locale[] |
getAvailableLocales() |
Returns an array of all locales for which the
getInstance methods of this class can return
localized instances.
|
abstract CollationKey |
getCollationKey(String source) |
Transforms the String into a series of bits that can be compared bitwise
to other CollationKeys.
|
int |
getDecomposition() |
Get the decomposition mode of this Collator.
|
static Collator |
getInstance() |
Gets the Collator for the current default locale.
|
static Collator |
getInstance(Locale desiredLocale) |
Gets the Collator for the desired locale.
|
int |
getStrength() |
Returns this Collator's strength property.
|
abstract int |
hashCode() |
Generates the hash code for this Collator.
|
void |
setDecomposition(int decompositionMode) |
Set the decomposition mode of this Collator.
|
void |
setStrength(int newStrength) |
Sets this Collator's strength property.
|
-
Methods inherited from interface java.util.Comparator
comparing, comparing, comparingDouble, comparingInt, comparingLong, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
-
Field Detail
-
PRIMARY
public static final int PRIMARY
Collator strength value. When set, only PRIMARY differences are
considered significant during comparison. The assignment of strengths
to language features is locale dependant. A common example is for
different base letters ("a" vs "b") to be considered a PRIMARY difference.
- See Also:
setStrength(int),
getStrength(),
Constant Field Values
-
SECONDARY
public static final int SECONDARY
Collator strength value. When set, only SECONDARY and above differences are
considered significant during comparison. The assignment of strengths
to language features is locale dependant. A common example is for
different accented forms of the same base letter ("a" vs "�") to be
considered a SECONDARY difference.
- See Also:
setStrength(int),
getStrength(),
Constant Field Values
-
TERTIARY
public static final int TERTIARY
Collator strength value. When set, only TERTIARY and above differences are
considered significant during comparison. The assignment of strengths
to language features is locale dependant. A common example is for
case differences ("a" vs "A") to be considered a TERTIARY difference.
- See Also:
setStrength(int),
getStrength(),
Constant Field Values
-
IDENTICAL
public static final int IDENTICAL
Collator strength value. When set, all differences are
considered significant during comparison. The assignment of strengths
to language features is locale dependant. A common example is for control
characters ("\u0001" vs "\u0002") to be considered equal at the
PRIMARY, SECONDARY, and TERTIARY levels but different at the IDENTICAL
level. Additionally, differences between pre-composed accents such as
"\u00C0" (A-grave) and combining accents such as "A\u0300"
(A, combining-grave) will be considered significant at the IDENTICAL
level if decomposition is set to NO_DECOMPOSITION.
- See Also:
- Constant Field Values
-
NO_DECOMPOSITION
public static final int NO_DECOMPOSITION
Decomposition mode value. With NO_DECOMPOSITION
set, accented characters will not be decomposed for collation. This
is the default setting and provides the fastest collation but
will only produce correct results for languages that do not use accents.
- See Also:
getDecomposition(),
setDecomposition(int),
Constant Field Values
-
Method Detail
-
getCollationKey
public abstract 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.
- 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.
- See Also:
CollationKey,
compare(java.lang.String, java.lang.String)
-
equals
public boolean equals(String source,
String target)
Convenience method for comparing the equality of two strings based on
this Collator's collation rules.
- Parameters:
source - the source string to be compared with.
target - the target string to be compared with.
- Returns:
- true if the strings are equal according to the collation
rules. false, otherwise.
- See Also:
compare(java.lang.String, java.lang.String)
-
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.
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 one of
PRIMARY, SECONDARY, TERTIARY or IDENTICAL.
- See Also:
getStrength(),
PRIMARY,
SECONDARY,
TERTIARY,
IDENTICAL
-
clone
public Object clone()
Overrides Cloneable
- Overrides:
clone in class Object
- Returns:
- a clone of this instance.
- See Also:
Cloneable
Java™ Platform Standard Ed. 8
Submit a bug or feature For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. Copyright © 1993, 2026, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
|