Top Description Fields Constructors Methods
com.ibm.icu.text

public final Class RawCollationKey

extends ByteArrayWrapper
Class Inheritance
Imports
com.ibm.icu.util.ByteArrayWrapper

Simple class wrapper to store the internal byte representation of a CollationKey. Unlike the CollationKey, this class do not contain information on the source string the sort order represents. RawCollationKey is mutable and users can reuse its objects with the method in RuleBasedCollator.getRawCollationKey(..).

Please refer to the documentation on CollationKey for a detail description on the internal byte representation. Note the internal byte representation is always null-terminated.

Example of use:
String str[] = {.....}; RuleBasedCollator collator = (RuleBasedCollator)Collator.getInstance(); RawCollationKey key = new RawCollationKey(128); for (int i = 0; i < str.length; i ++) { collator.getRawCollationKey(str[i], key); // do something with key.bytes }

Note

Comparison between RawCollationKeys created by different Collators might return incorrect results. See class documentation for Collator.

ICU Status
Stable since ICU 2.8.
See Also
RuleBasedCollator, CollationKey

Field Summary

Inherited from com.ibm.icu.util.ByteArrayWrapper:
bytessize

Constructor Summary

AccessConstructor and Description
public
RawCollationKey()

Default constructor, internal byte array is null and its size set to 0.

public
RawCollationKey(int
length of internal byte array
capacity
)

RawCollationKey created with an empty internal byte array of length capacity.

public
RawCollationKey(byte[]
byte array to be adopted by RawCollationKey
bytes
)

RawCollationKey created, adopting bytes as the internal byte array.

public
RawCollationKey(byte[]
the byte array to adopt
bytesToAdopt
,
int
the length of valid data in the byte array
size
)

Construct a RawCollationKey from a byte array and size.

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

-1, 0, or 1 as this compares less than, equal to, or greater than rhs.
compareTo
(RawCollationKey
the RawCollationKey to compare to.
rhs
)

Implements java.lang.Comparable.compareTo.

Compare this RawCollationKey to another, which must not be null.
Inherited from com.ibm.icu.util.ByteArrayWrapper:
appendcompareToensureCapacityequalshashCodereleaseBytessettoString

Constructor Detail

RawCollationKeyback to summary
public RawCollationKey()

Default constructor, internal byte array is null and its size set to 0.

ICU Status
Stable since ICU 2.8.
RawCollationKeyback to summary
public RawCollationKey(int capacity)

RawCollationKey created with an empty internal byte array of length capacity. Size of the internal byte array will be set to 0.

Parameters
capacity:int

length of internal byte array

ICU Status
Stable since ICU 2.8.
RawCollationKeyback to summary
public RawCollationKey(byte[] bytes)

RawCollationKey created, adopting bytes as the internal byte array. Size of the internal byte array will be set to 0.

Parameters
bytes:byte[]

byte array to be adopted by RawCollationKey

ICU Status
Stable since ICU 2.8.
RawCollationKeyback to summary
public RawCollationKey(byte[] bytesToAdopt, int size)

Construct a RawCollationKey from a byte array and size.

Parameters
bytesToAdopt:byte[]

the byte array to adopt

size:int

the length of valid data in the byte array

Exceptions
IndexOutOfBoundsException:
if bytesToAdopt == null and size != 0, or size < 0, or size > bytesToAdopt.length.
ICU Status
Stable since ICU 2.8.

Method Detail

compareToback to summary
public int compareTo(RawCollationKey rhs)

Implements java.lang.Comparable.compareTo.

Compare this RawCollationKey to another, which must not be null. This overrides the inherited implementation to ensure the returned values are -1, 0, or 1.

Parameters
rhs:RawCollationKey

the RawCollationKey to compare to.

Returns:int

-1, 0, or 1 as this compares less than, equal to, or greater than rhs.

Exceptions
ClassCastException:
if the other object is not a RawCollationKey.
ICU Status
Stable since ICU 4.4.