public final class RawCollationKey extends 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.
RuleBasedCollator
,
CollationKey
bytes, size
Constructor and Description |
---|
RawCollationKey()
Default constructor, internal byte array is null and its size set to 0.
|
RawCollationKey(byte[] bytes)
RawCollationKey created, adopting bytes as the internal byte array.
|
RawCollationKey(byte[] bytesToAdopt,
int size)
Construct a RawCollationKey from a byte array and size.
|
RawCollationKey(int capacity)
RawCollationKey created with an empty internal byte array of length
capacity.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(RawCollationKey rhs)
Compare this RawCollationKey to another, which must not be null.
|
append, compareTo, ensureCapacity, equals, hashCode, releaseBytes, set, toString
public RawCollationKey()
public RawCollationKey(int capacity)
capacity
- length of internal byte arraypublic RawCollationKey(byte[] bytes)
bytes
- byte array to be adopted by RawCollationKeypublic RawCollationKey(byte[] bytesToAdopt, int size)
bytesToAdopt
- the byte array to adoptsize
- the length of valid data in the byte arrayIndexOutOfBoundsException
- if bytesToAdopt == null and size != 0, or
size < 0, or size > bytesToAdopt.length.public int compareTo(RawCollationKey rhs)
rhs
- the RawCollationKey to compare to.ClassCastException
- if the other object is not a RawCollationKey.Copyright © 2016 Unicode, Inc. and others.