Strings from UTF-8. Instances of this class are reusable but are NOT threadsafe.
Instances are vended by Utf8StringDecoderPool#getOrCreate().
Users are expected to call close() when the decoder is no longer needed.
There are two ways of using this class:
decode(ByteBuffer, int) to decode the requested number of bytes from the given ByteBuffer in
a single step. Or,prepareDecode(int) to prepare the decoder to decode the requested number of bytes.partialDecode(ByteBuffer, boolean) to decode the available bytes from the byte buffer. This may
be repeated as more bytes are made available in the ByteBuffer, which is the caller's responsibility.finishDecode() to finish decoding and return the resulting String.decode(ByteBuffer, int) must not be called between calls to prepareDecode(int) and
finishDecode().
| Modifier and Type | Field and Description |
|---|---|
| private final CharBuffer | |
| private static final int | |
| private final CharsetDecoder | |
| private CharBuffer |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public String | Returns: the decoded Java String.a ByteBuffer containing UTF-8 bytes. utf8InputBuffer, int the number of bytes from the utf8InputBuffer to decode. numberOfBytes)Decodes the given number of UTF-8 bytes from the given ByteBuffer into a Java String. |
| public String | |
| public void | partialDecode(ByteBuffer
a ByteBuffer containing UTF-8 bytes. utf8InputBuffer, boolean true if the end of the UTF-8 sequence is expected to occur in the buffer; otherwise, false. endOfInput)Decodes the available bytes from the given ByteBuffer. |
| public void | prepareDecode(int
the number of bytes to decode. numberOfBytes)Prepares the decoder to decode the given number of UTF-8 bytes. |
| reusableUtf8DecodingBuffer | back to summary |
|---|---|
| private final CharBuffer reusableUtf8DecodingBuffer | |
| UTF8_BUFFER_SIZE_IN_BYTES | back to summary |
|---|---|
| private static final int UTF8_BUFFER_SIZE_IN_BYTES | |
| utf8CharsetDecoder | back to summary |
|---|---|
| private final CharsetDecoder utf8CharsetDecoder | |
| utf8DecodingBuffer | back to summary |
|---|---|
| private CharBuffer utf8DecodingBuffer | |
| Utf8StringDecoder | back to summary |
|---|---|
| pack-priv Utf8StringDecoder(Pool<Utf8StringDecoder> pool) | |
| decode | back to summary |
|---|---|
| public String decode(ByteBuffer utf8InputBuffer, int numberOfBytes) Decodes the given number of UTF-8 bytes from the given ByteBuffer into a Java String.
| |
| finishDecode | back to summary |
|---|---|
| public String finishDecode() Finishes decoding and returns the resulting String.
| |
| partialDecode | back to summary |
|---|---|
| public void partialDecode(ByteBuffer utf8InputBuffer, boolean endOfInput) Decodes the available bytes from the given ByteBuffer.
| |
| prepareDecode | back to summary |
|---|---|
| public void prepareDecode(int numberOfBytes) Prepares the decoder to decode the given number of UTF-8 bytes.
| |