|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.lucene.util.IndexableBinaryStringTools
public final class IndexableBinaryStringTools
Provides support for converting byte sequences to Strings and back again. The resulting Strings preserve the original byte sequences' sort order.
The Strings are constructed using a Base 8000h encoding of the original binary data - each char of an encoded String represents a 15-bit chunk from the byte sequence. Base 8000h was chosen because it allows for all lower 15 bits of char to be used without restriction; the surrogate range [U+D8000-U+DFFF] does not represent valid chars, and would require complicated handling to avoid them and allow use of char's high bit. Although unset bits are used as padding in the final char, the original byte sequence could contain trailing bytes with no set bits (null bytes): padding is indistinguishable from valid information. To overcome this problem, a char is appended, indicating the number of encoded bytes in the final content char. Some methods in this class are defined over CharBuffers and ByteBuffers, but these are deprecated in favor of methods that operate directly on byte[] and char[] arrays. Note that this class calls array() and arrayOffset() on the CharBuffers and ByteBuffers it uses, so only wrapped arrays may be used. This class interprets the arrayOffset() and limit() values returned by its input buffers as beginning and end+1 positions on the wrapped array, respectively; similarly, on the output buffer, arrayOffset() is the first position written to, and limit() is set to one past the final output array position. WARNING: This means that the deprecated Buffer-based methods only work correctly with buffers that have an offset of 0. For example, they will not correctly interpret buffers returned byByteBuffer.slice()
.
Method Summary | |
---|---|
static void |
decode(char[] inputArray,
int inputOffset,
int inputLength,
byte[] outputArray,
int outputOffset,
int outputLength)
Decodes the input char sequence into the output byte sequence. |
static ByteBuffer |
decode(CharBuffer input)
Deprecated. Use decode(char[], int, int, byte[], int, int)
instead. This method will be removed in Lucene 4.0 |
static void |
decode(CharBuffer input,
ByteBuffer output)
Deprecated. Use decode(char[], int, int, byte[], int, int)
instead. This method will be removed in Lucene 4.0 |
static void |
encode(byte[] inputArray,
int inputOffset,
int inputLength,
char[] outputArray,
int outputOffset,
int outputLength)
Encodes the input byte sequence into the output char sequence. |
static CharBuffer |
encode(ByteBuffer input)
Deprecated. Use encode(byte[], int, int, char[], int, int)
instead. This method will be removed in Lucene 4.0 |
static void |
encode(ByteBuffer input,
CharBuffer output)
Deprecated. Use encode(byte[], int, int, char[], int, int)
instead. This method will be removed in Lucene 4.0 |
static int |
getDecodedLength(char[] encoded,
int offset,
int length)
Returns the number of bytes required to decode the given char sequence. |
static int |
getDecodedLength(CharBuffer encoded)
Deprecated. Use getDecodedLength(char[], int, int) instead. This
method will be removed in Lucene 4.0 |
static int |
getEncodedLength(byte[] inputArray,
int inputOffset,
int inputLength)
Returns the number of chars required to encode the given bytes. |
static int |
getEncodedLength(ByteBuffer original)
Deprecated. Use getEncodedLength(byte[], int, int) instead. This
method will be removed in Lucene 4.0 |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
@Deprecated public static int getEncodedLength(ByteBuffer original) throws IllegalArgumentException
getEncodedLength(byte[], int, int)
instead. This
method will be removed in Lucene 4.0
original
- The byte sequence to be encoded. Must be backed by an
array.
IllegalArgumentException
- If the given ByteBuffer is not backed by
an arraypublic static int getEncodedLength(byte[] inputArray, int inputOffset, int inputLength)
inputArray
- byte sequence to be encodedinputOffset
- initial offset into inputArrayinputLength
- number of bytes in inputArray
@Deprecated public static int getDecodedLength(CharBuffer encoded) throws IllegalArgumentException
getDecodedLength(char[], int, int)
instead. This
method will be removed in Lucene 4.0
encoded
- The char sequence to be decoded. Must be backed by an array.
IllegalArgumentException
- If the given CharBuffer is not backed by
an arraypublic static int getDecodedLength(char[] encoded, int offset, int length)
encoded
- char sequence to be decodedoffset
- initial offsetlength
- number of characters
@Deprecated public static void encode(ByteBuffer input, CharBuffer output)
encode(byte[], int, int, char[], int, int)
instead. This method will be removed in Lucene 4.0
getEncodedLength(java.nio.ByteBuffer)
.
input
- The byte sequence to encodeoutput
- Where the char sequence encoding result will go. The limit is
set to one past the position of the final char.
IllegalArgumentException
- If either the input or the output buffer
is not backed by an arraypublic static void encode(byte[] inputArray, int inputOffset, int inputLength, char[] outputArray, int outputOffset, int outputLength)
getEncodedLength(byte[], int, int)
.
inputArray
- byte sequence to be encodedinputOffset
- initial offset into inputArrayinputLength
- number of bytes in inputArrayoutputArray
- char sequence to store encoded resultoutputOffset
- initial offset into outputArrayoutputLength
- length of output, must be getEncodedLength@Deprecated public static void decode(CharBuffer input, ByteBuffer output)
decode(char[], int, int, byte[], int, int)
instead. This method will be removed in Lucene 4.0
getDecodedLength(java.nio.CharBuffer)
.
input
- The char sequence to decodeoutput
- Where the byte sequence decoding result will go. The limit is
set to one past the position of the final char.
IllegalArgumentException
- If either the input or the output buffer
is not backed by an arraypublic static void decode(char[] inputArray, int inputOffset, int inputLength, byte[] outputArray, int outputOffset, int outputLength)
getDecodedLength(char[], int, int)
.
inputArray
- char sequence to be decodedinputOffset
- initial offset into inputArrayinputLength
- number of chars in inputArrayoutputArray
- byte sequence to store encoded resultoutputOffset
- initial offset into outputArrayoutputLength
- length of output, must be
getDecodedLength(inputArray, inputOffset, inputLength)@Deprecated public static ByteBuffer decode(CharBuffer input)
decode(char[], int, int, byte[], int, int)
instead. This method will be removed in Lucene 4.0
encode(java.nio.ByteBuffer)
or
encode(java.nio.ByteBuffer, java.nio.CharBuffer)
.
input
- The char sequence to decode
IllegalArgumentException
- If the input buffer is not backed by an
array@Deprecated public static CharBuffer encode(ByteBuffer input)
encode(byte[], int, int, char[], int, int)
instead. This method will be removed in Lucene 4.0
input
- The byte sequence to encode
IllegalArgumentException
- If the input buffer is not backed by an
array
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |