Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

java.text
Class CollationKey  view CollationKey download CollationKey.java

java.lang.Object
  extended byjava.text.CollationKey
All Implemented Interfaces:
java.lang.Comparable

public final class CollationKey
extends java.lang.Object
implements java.lang.Comparable

This class represents a pre-computed series of bits representing a String for under a particular Collator. This value may be compared bitwise against another CollationKey representing a different String under the same Collator in a manner than is usually more efficient than using the raw Collator compare methods. There is overhead associated with calculating this value, so it is generally not advisable to compute CollationKey's unless multiple comparisons against a String will be done. (For example, in a sort routine).

This class cannot be instantiated directly. Instead, a CollationKey is created by calling the getCollationKey method on an instance of Collator.


Field Summary
private  Collator collator
          This is the Collator this object was created from.
private  byte[] key
          This is the bit value for this key.
private  java.lang.String originalText
          This is the String this object represents.
 
Constructor Summary
(package private) CollationKey(Collator collator, java.lang.String originalText, byte[] key)
           
 
Method Summary
 int compareTo(CollationKey ck)
          This method compares the specified object to this one.
 int compareTo(java.lang.Object obj)
          This method compares the specified object to this one.
 boolean equals(java.lang.Object obj)
          This method tests the specified Object for equality with this object.
 java.lang.String getSourceString()
          This method returns the String that this object was created from.
 int hashCode()
          This method returns a hash value for this object.
 byte[] toByteArray()
          This method returns the collation bit sequence as a byte array.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

collator

private Collator collator
This is the Collator this object was created from.


originalText

private java.lang.String originalText
This is the String this object represents.


key

private byte[] key
This is the bit value for this key.

Constructor Detail

CollationKey

CollationKey(Collator collator,
             java.lang.String originalText,
             byte[] key)
Method Detail

compareTo

public int compareTo(CollationKey ck)
This method compares the specified object to this one. An integer is returned which indicates whether the specified object is less than, greater than, or equal to this object.


compareTo

public int compareTo(java.lang.Object obj)
This method compares the specified object to this one. The specified object must be an instance of CollationKey or an exception will be thrown. An integer is returned which indicates whether the specified object is less than, greater than, or equal to this object.

Specified by:
compareTo in interface java.lang.Comparable

equals

public boolean equals(java.lang.Object obj)
This method tests the specified Object for equality with this object. This will be true if and only if:

  • The specified object must not be null
  • The specified object is an instance of CollationKey.
  • The specified object was created from the same Collator as this object.
  • The specified object has the same source string and bit key as this object.


getSourceString

public java.lang.String getSourceString()
This method returns the String that this object was created from.


hashCode

public int hashCode()
This method returns a hash value for this object. The hash value returned will be the hash code of the bit key so that identical bit keys will return the same value.


toByteArray

public byte[] toByteArray()
This method returns the collation bit sequence as a byte array.