java.text
public
abstract
class
java.text.Collator
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.
Known Direct Subclasses
Summary
Constants
|
|
|
Value |
|
int |
CANONICAL_DECOMPOSITION |
Constant used to specify the decomposition rule. |
1 |
0x00000001 |
int |
FULL_DECOMPOSITION |
Constant used to specify the decomposition rule. |
2 |
0x00000002 |
int |
IDENTICAL |
Constant used to specify the collation strength. |
3 |
0x00000003 |
int |
NO_DECOMPOSITION |
Constant used to specify the decomposition rule. |
0 |
0x00000000 |
int |
PRIMARY |
Constant used to specify the collation strength. |
0 |
0x00000000 |
int |
SECONDARY |
Constant used to specify the collation strength. |
1 |
0x00000001 |
int |
TERTIARY |
Constant used to specify the collation strength. |
2 |
0x00000002 |
Protected Constructors
Public Methods
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
Details
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
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
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
public
static
Locale[]
getAvailableLocales()
Gets the list of installed Locales which support Collator.
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. |
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.
public
static
Collator
getInstance(Locale locale)
Returns a Collator instance which is appropriate for the specified
Locale.
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.
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 |
public
void
setStrength(int value)
Sets the strength value for this Collator.
Parameters
value
| the strength value, either PRIMARY, SECONDARY, TERTIARY, or
IDENTICAL |