Package io.servicetalk.buffer.netty
Class BufferUtils
java.lang.Object
io.servicetalk.buffer.netty.BufferUtils
Internal utilities for
Buffers.-
Method Summary
Modifier and TypeMethodDescriptionstatic io.netty.buffer.ByteBufextractByteBufOrCreate(Buffer buffer) Converts the passedbuffertoByteBuf, creating a newByteBufinstance if required.static io.netty.buffer.ByteBufAllocatorgetByteBufAllocator(BufferAllocator allocator) Returns theByteBufAllocatortaking theBufferAllocatorinto account.static intmaxUtf8Bytes(CharSequence data) Calculate the max bytes length of UTF8 character sequence.static BuffernewBufferFrom(io.netty.buffer.ByteBuf buffer) Return aBufferfor the givenByteBuf.static io.netty.buffer.ByteBufReturn aByteBuffor the given buffer.static io.netty.buffer.ByteBuftoByteBufNoThrow(Buffer buffer) Converts the passedbuffertoByteBuf, or returnsnullif not possible.
-
Method Details
-
toByteBuf
Return aByteBuffor the given buffer.- Parameters:
buffer- the buffer.- Returns:
- a
ByteBuf.
-
extractByteBufOrCreate
Converts the passedbuffertoByteBuf, creating a newByteBufinstance if required.- Parameters:
buffer- the buffer.- Returns:
- a
ByteBuf.
-
toByteBufNoThrow
Converts the passedbuffertoByteBuf, or returnsnullif not possible.- Parameters:
buffer- TheBufferto convert.- Returns:
- a
ByteBufequivalent ofbuffer, ornullif no equivalent can be found.
-
getByteBufAllocator
Returns theByteBufAllocatortaking theBufferAllocatorinto account.- Parameters:
allocator- theBufferAllocatorthat is used.- Returns:
- the
ByteBufAllocatorto use.
-
newBufferFrom
Return aBufferfor the givenByteBuf.- Parameters:
buffer- the buffer to wrap.- Returns:
- the created buffer.
-
maxUtf8Bytes
Calculate the max bytes length of UTF8 character sequence.- Parameters:
data- the data to be encoded in UTF8.- Returns:
- max bytes length of UTF8 character sequence.
-