加载中...
The Wayback Machine - https://sup1a9wrlpyh5li9ro.vcoronado.top/web/20090226230135/http://developer.android.com:80/reference/java/text/Collator.html
public abstract class

Collator

extends Object
implements Cloneable Comparator<T>
java.lang.Object
   ↳ java.text.Collator
Known Direct Subclasses

Class Overview

Collator is an abstract class which is the root of classes which provide Locale specific String comparison to determine their ordering with respect to each other.

Summary

Constants
int CANONICAL_DECOMPOSITION Constant used to specify the decomposition rule.
int FULL_DECOMPOSITION Constant used to specify the decomposition rule.
int IDENTICAL Constant used to specify the collation strength.
int NO_DECOMPOSITION Constant used to specify the decomposition rule.
int PRIMARY Constant used to specify the collation strength.
int SECONDARY Constant used to specify the collation strength.
int TERTIARY Constant used to specify the collation strength.
Protected Constructors
Collator()
Constructs a new instance of this Collator.
Public Methods
Object clone()
Returns a new Collator with the same decomposition rule and strength value as this Collator.
abstract int compare(String string1, String string2)
Compares the two Strings to determine their relative ordering.
int compare(Object object1, Object object2)
Compares the two objects to determine their relative ordering.
boolean equals(String string1, String string2)
Compares the two Strings using the collation rules to determine if they are equal.
boolean equals(Object object)
Compares the specified object to this Collator and answer if they are equal.
static Locale[] getAvailableLocales()
Gets the list of installed Locales which support Collator.
abstract CollationKey getCollationKey(String string)
Returns a CollationKey for the specified String for this Collator with the current decomposition rule and strength value.
int getDecomposition()
Returns the decomposition rule for this Collator.
static Collator getInstance()
Returns a Collator instance which is appropriate for the default Locale.
static Collator getInstance(Locale locale)
Returns a Collator instance which is appropriate for the specified Locale.
int getStrength()
Returns the strength value for this Collator.
abstract int hashCode()
Returns an integer hash code for the receiver.
void setDecomposition(int value)
Sets the decomposition rule for this Collator.
void setStrength(int value)
Sets the strength value for this Collator.
[Expand]
Inherited Methods
From class java.lang.Object
From interface java.util.Comparator

Constants

public static final int CANONICAL_DECOMPOSITION

Constant used to specify the decomposition rule.

Constant Value: 1 (0x00000001)

public static final int FULL_DECOMPOSITION

Constant used to specify the decomposition rule.

Constant Value: 2 (0x00000002)

public static final int IDENTICAL

Constant used to specify the collation strength.

Constant Value: 3 (0x00000003)

public static final int NO_DECOMPOSITION

Constant used to specify the decomposition rule.

Constant Value: 0 (0x00000000)

public static final int PRIMARY

Constant used to specify the collation strength.

Constant Value: 0 (0x00000000)

public static final int SECONDARY

Constant used to specify the collation strength.

Constant Value: 1 (0x00000001)

public static final int TERTIARY

Constant used to specify the collation strength.

Constant Value: 2 (0x00000002)

Protected Constructors

protected Collator ()

Constructs a new instance of this Collator.

Public Methods

public Object clone ()

Returns a new Collator with the same decomposition rule and strength value as this Collator.

Returns
  • a shallow copy of this Collator
See Also

public abstract int compare (String string1, String string2)

Compares the two Strings to determine their relative ordering.

Parameters
string1 the first String to compare
string2 the second String to compare
Returns
  • an int < 0 if string1 is less than string2, 0 if they are equal, and > 0 if string1 is greater than string2

public int compare (Object object1, Object object2)

Compares the two objects to determine their relative ordering. The objects must be Strings.

Parameters
object1 the first String to compare
object2 the second String to compare
Returns
  • an int < 0 if object1 is less than object2, 0 if they are equal, and > 0 if object1 is greater than object2
Throws
ClassCastException when the objects are not Strings

public boolean equals (String string1, String string2)

Compares the two Strings using the collation rules to determine if they are equal.

Parameters
string1 the first String to compare
string2 the second String to compare
Returns
  • true if the strings are equal using the collation rules, false otherwise

public boolean equals (Object object)

Compares the specified object to this Collator and answer if they are equal. The object must be an instance of Collator and have the same strength and decomposition values.

Parameters
object the object to compare with this object
Returns
  • true if the specified object is equal to this Collator, false otherwise
See Also

public static Locale[] getAvailableLocales ()

Gets the list of installed Locales which support Collator.

Returns
  • an array of Locale

public abstract CollationKey getCollationKey (String string)

Returns a CollationKey for the specified String for this Collator with the current decomposition rule and strength value.

Parameters
string the collation key.
Returns
  • a CollationKey

public int getDecomposition ()

Returns the decomposition rule for this Collator.

Returns
  • the decomposition rule, either NO_DECOMPOSITION, CANONICAL_DECOMPOSITION or FULL_DECOMPOSITION

public static Collator getInstance ()

Returns a Collator instance which is appropriate for the default Locale.

Returns
  • a Collator

public static Collator getInstance (Locale locale)

Returns a Collator instance which is appropriate for the specified Locale.

Parameters
locale the Locale
Returns
  • a Collator

public int getStrength ()

Returns the strength value for this Collator.

Returns
  • the strength value, either PRIMARY, SECONDARY, TERTIARY, or IDENTICAL

public abstract int hashCode ()

Returns an integer hash code for the receiver. Objects which are equal answer the same value for this method.

Returns
  • the receiver's hash

public void setDecomposition (int value)

Sets the decomposition rule for this Collator.

Parameters
value the decomposition rule, either NO_DECOMPOSITION, CANONICAL_DECOMPOSITION or FULL_DECOMPOSITION
Throws
IllegalArgumentException when the decomposition rule is not valid

public void setStrength (int value)

Sets the strength value for this Collator.

Parameters
value the strength value, either PRIMARY, SECONDARY, TERTIARY, or IDENTICAL
Throws
IllegalArgumentException when the strength value is not valid