| Constructor and Description |
|---|
Utf8() |
| Modifier and Type | Method and Description |
|---|---|
abstract String |
decodeUtf8(ByteBuffer buffer,
int offset,
int length)
Decodes the given UTF-8 portion of the
ByteBuffer into a String. |
abstract int |
encodedLength(CharSequence sequence)
Returns the number of bytes in the UTF-8-encoded form of
sequence. |
abstract void |
encodeUtf8(CharSequence in,
ByteBuffer out)
Encodes the given characters to the target
ByteBuffer using UTF-8 encoding. |
static Utf8 |
getDefault()
Get the default UTF-8 processor.
|
static void |
setDefault(Utf8 instance)
Set the default instance of the UTF-8 processor.
|
public abstract int encodedLength(CharSequence sequence)
sequence. For a string,
this method is equivalent to string.getBytes(UTF_8).length, but is more efficient in
both time and space.IllegalArgumentException - if sequence contains ill-formed UTF-16 (unpaired
surrogates)public abstract void encodeUtf8(CharSequence in, ByteBuffer out)
ByteBuffer using UTF-8 encoding.
Selects an optimal algorithm based on the type of ByteBuffer (i.e. heap or direct)
and the capabilities of the platform.
in - the source string to be encodedout - the target buffer to receive the encoded string.public abstract String decodeUtf8(ByteBuffer buffer, int offset, int length)
ByteBuffer into a String.IllegalArgumentException - if the input is not valid UTF-8.public static Utf8 getDefault()
public static void setDefault(Utf8 instance)
instance - the new instance to useCopyright © 2020. All rights reserved.