All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class java.text.CollationKey

java.lang.Object
   |
   +----java.text.CollationKey

public final class CollationKey
extends Object
Collation keys are generated by the Collation class. These are not real String objects. Use the CollationKey methods to compare and manipulate collation keys.

Example of use:

     Collation myCollation = Collation.getDefault(Locale.US);
     CollationKey key1 = myCollation.getCollationKey("abc");
     CollationKey key2 = myCollation.getCollationKey("ABC");
     // do something
 

Because Collation.compare()'s algorithm is complex, it is faster to sort long lists of words by retrieving collation keys with Collation.getCollationKey(). You can then cache the collation keys and compare them using CollationKey.compareTo(). The following is the characteristics of collation keys:

See Also:
Collation, TableCollation, SortKey

Method Index

 o compareTo(CollationKey)
Compares the equality between two collation keys.
 o equals(Object)
Compare if two objects are the same.
 o hashCode()
Creates an integer that is unique to the collation key.
 o toString()
The string value of a collation key.

Methods

 o compareTo
  public byte compareTo(CollationKey target)
Compares the equality between two collation keys. Handles indefinite number of ignorable characters. The generated collation key must be compared with CollationKey.compareTo().

Example of use:

     Collation myCollation = Collation.getDefault(Locale.US);
     CollationKey key1 = myCollation.getCollationKey("abc");
     CollationKey key2 = myCollation.getCollationKey("ABC");
     // Use java.text.CollationKey.compareTo() to compare
     // the keys. Result will be Collation.LESS (key1 < key2)
     byte result = key1.compareTo(key2);
 

Parameters:
target - the target collation key to be used to compare with
Returns:
Returns LESS if this is less than target, GREATER if this is greater than target and EQUAL otherwise.
See Also:
getCollationKey, compareTo
 o toString
  public String toString()
The string value of a collation key. For debugging purpose only, do not modify the string.

Returns:
the string value of a collation key.
Overrides:
toString in class Object
 o equals
  public boolean equals(Object source)
Compare if two objects are the same.

Parameters:
source - object to compare to
Returns:
true if equal, false otherwise
Overrides:
equals in class Object
 o hashCode
  public int hashCode()
Creates an integer that is unique to the collation key.

Example of use:

     Collation myCollation = Collation.getDefault(Locale.US);
     CollationKey key1 = myCollation.getCollationKey("abc");
     CollationKey key2 = myCollation.getCollationKey("ABC");
     // key1.hashCode() != key2.hashCode()
 

Returns:
the hash value of a collation key
Overrides:
hashCode in class Object
See Also:
hashCode

All Packages  Class Hierarchy  This Package  Previous  Next  Index