Package io.objectbox.flatbuffers
Class Utf8
java.lang.Object
io.objectbox.flatbuffers.Utf8
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract StringdecodeUtf8(ByteBuffer buffer, int offset, int length) Decodes the given UTF-8 portion of theByteBufferinto aString.abstract intencodedLength(CharSequence sequence) Returns the number of bytes in the UTF-8-encoded form ofsequence.abstract voidencodeUtf8(CharSequence in, ByteBuffer out) Encodes the given characters to the targetByteBufferusing UTF-8 encoding.static intencodeUtf8CodePoint(CharSequence in, int start, byte[] out) Encode a Java's CharSequence UTF8 codepoint into a byte array.static Utf8Get the default UTF-8 processor.static voidsetDefault(Utf8 instance) Set the default instance of the UTF-8 processor.
-
Constructor Details
-
Utf8
public Utf8()
-
-
Method Details
-
encodedLength
Returns the number of bytes in the UTF-8-encoded form ofsequence. For a string, this method is equivalent tostring.getBytes(UTF_8).length, but is more efficient in both time and space.- Throws:
IllegalArgumentException- ifsequencecontains ill-formed UTF-16 (unpaired surrogates)
-
encodeUtf8
Encodes the given characters to the targetByteBufferusing UTF-8 encoding.Selects an optimal algorithm based on the type of
ByteBuffer(i.e. heap or direct) and the capabilities of the platform.- Parameters:
in- the source string to be encodedout- the target buffer to receive the encoded string.
-
decodeUtf8
Decodes the given UTF-8 portion of theByteBufferinto aString.- Throws:
IllegalArgumentException- if the input is not valid UTF-8.
-
getDefault
Get the default UTF-8 processor.- Returns:
- the default processor
-
setDefault
Set the default instance of the UTF-8 processor.- Parameters:
instance- the new instance to use
-
encodeUtf8CodePoint
Encode a Java's CharSequence UTF8 codepoint into a byte array.- Parameters:
in- CharSequence to be encodedstart- start position of the first char in the codepointout- byte array of 4 bytes to be filled- Returns:
- return the amount of bytes occupied by the codepoint
-