Build 1.0_r1(from source)

java.text
Class Collator

java.lang.Object
  extended by java.text.Collator
All Implemented Interfaces:
Cloneable, Comparator<Object>
Direct Known Subclasses:
RuleBasedCollator

public abstract class Collator
extends Object
implements Comparator<Object>, Cloneable

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.


Field Summary
static int CANONICAL_DECOMPOSITION
          Constant used to specify the decomposition rule.
(package private) static int EQUAL
           
static int FULL_DECOMPOSITION
          Constant used to specify the decomposition rule.
(package private) static int GREATER
           
(package private)  com.ibm.icu4jni.text.Collator icuColl
           
static int IDENTICAL
          Constant used to specify the collation strength.
(package private) static int LESS
           
static int NO_DECOMPOSITION
          Constant used to specify the decomposition rule.
static int PRIMARY
          Constant used to specify the collation strength.
static int SECONDARY
          Constant used to specify the collation strength.
static int TERTIARY
          Constant used to specify the collation strength.
 
Constructor Summary
protected Collator()
          Constructs a new instance of this Collator.
(package private) Collator(com.ibm.icu4jni.text.Collator wrapper)
           
 
Method Summary
 Object clone()
          Returns a new Collator with the same decomposition rule and strength value as this Collator.
 int compare(Object object1, Object object2)
          Compares the two objects to determine their relative ordering.
abstract  int compare(String string1, String string2)
          Compares the two Strings to determine their relative ordering.
 boolean equals(Object object)
          Compares the specified object to this Collator and answer if they are equal.
 boolean equals(String string1, String string2)
          Compares the two Strings using the collation rules to determine 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.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EQUAL

static final int EQUAL
See Also:
Constant Field Values

GREATER

static final int GREATER
See Also:
Constant Field Values

LESS

static final int LESS
See Also:
Constant Field Values

NO_DECOMPOSITION

public static final int NO_DECOMPOSITION
Constant used to specify the decomposition rule.

See Also:
Constant Field Values

CANONICAL_DECOMPOSITION

public static final int CANONICAL_DECOMPOSITION
Constant used to specify the decomposition rule.

See Also:
Constant Field Values

FULL_DECOMPOSITION

public static final int FULL_DECOMPOSITION
Constant used to specify the decomposition rule.

See Also:
Constant Field Values

PRIMARY

public static final int PRIMARY
Constant used to specify the collation strength.

See Also:
Constant Field Values

SECONDARY

public static final int SECONDARY
Constant used to specify the collation strength.

See Also:
Constant Field Values

TERTIARY

public static final int TERTIARY
Constant used to specify the collation strength.

See Also:
Constant Field Values

IDENTICAL

public static final int IDENTICAL
Constant used to specify the collation strength.

See Also:
Constant Field Values

icuColl

com.ibm.icu4jni.text.Collator icuColl
Constructor Detail

Collator

Collator(com.ibm.icu4jni.text.Collator wrapper)

Collator

protected Collator()
Constructs a new instance of this Collator.

Method Detail

clone

public Object clone()
Returns a new Collator with the same decomposition rule and strength value as this Collator.

Overrides:
clone in class Object
Returns:
a shallow copy of this Collator
See Also:
Cloneable

compare

public int compare(Object object1,
                   Object object2)
Compares the two objects to determine their relative ordering. The objects must be Strings.

Specified by:
compare in interface Comparator<Object>
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

compare

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

equals

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.

Specified by:
equals in interface Comparator<Object>
Overrides:
equals in class Object
Parameters:
object - the object to compare with this object
Returns:
true if the specified object is equal to this Collator, false otherwise
See Also:
hashCode()

equals

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

getAvailableLocales

public static Locale[] getAvailableLocales()
Gets the list of installed Locales which support Collator.

Returns:
an array of Locale

getCollationKey

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

getDecomposition

public int getDecomposition()
Returns the decomposition rule for this Collator.

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

getInstance

public static Collator getInstance()
Returns a Collator instance which is appropriate for the default Locale.

Returns:
a Collator

getInstance

public static Collator getInstance(Locale locale)
Returns a Collator instance which is appropriate for the specified Locale.

Parameters:
locale - the Locale
Returns:
a Collator

getStrength

public int getStrength()
Returns the strength value for this Collator.

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

hashCode

public abstract int hashCode()
Returns an integer hash code for the receiver. Objects which are equal answer the same value for this method.

Overrides:
hashCode in class Object
Returns:
the receiver's hash
See Also:
equals(Object), equals(String, String)

setDecomposition

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

setStrength

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

Build 1.0_r1(from source)

Please submit a feedback, bug or feature