public final class BufferUtil
extends java.lang.Object
Buffer
s.Modifier and Type | Method and Description |
---|---|
static io.netty.buffer.ByteBuf |
extractByteBufOrCreate(Buffer buffer)
Converts the passed
buffer to ByteBuf , creating a new ByteBuf instance if required. |
static io.netty.buffer.ByteBufAllocator |
getByteBufAllocator(BufferAllocator allocator)
Returns the
ByteBufAllocator taking the BufferAllocator into account. |
static int |
maxUtf8Bytes(java.lang.CharSequence data)
Calculate the max bytes length of UTF8 character sequence.
|
static Buffer |
newBufferFrom(io.netty.buffer.ByteBuf buffer)
Return a
Buffer for the given ByteBuf . |
static io.netty.buffer.ByteBuf |
toByteBuf(Buffer buffer)
Return a
ByteBuf for the given buffer. |
static io.netty.buffer.ByteBuf |
toByteBufNoThrow(Buffer buffer)
Converts the passed
buffer to ByteBuf , or returns null if not possible. |
public static io.netty.buffer.ByteBuf toByteBuf(Buffer buffer)
ByteBuf
for the given buffer.buffer
- the buffer.ByteBuf
.public static io.netty.buffer.ByteBuf extractByteBufOrCreate(Buffer buffer)
buffer
to ByteBuf
, creating a new ByteBuf
instance if required.buffer
- the buffer.ByteBuf
.@Nullable public static io.netty.buffer.ByteBuf toByteBufNoThrow(Buffer buffer)
buffer
to ByteBuf
, or returns null
if not possible.buffer
- The Buffer
to convert.ByteBuf
equivalent of buffer
, or null
if no equivalent can be found.public static io.netty.buffer.ByteBufAllocator getByteBufAllocator(BufferAllocator allocator)
ByteBufAllocator
taking the BufferAllocator
into account.allocator
- the BufferAllocator
that is used.ByteBufAllocator
to use.public static Buffer newBufferFrom(io.netty.buffer.ByteBuf buffer)
Buffer
for the given ByteBuf
.buffer
- the buffer to wrap.public static int maxUtf8Bytes(java.lang.CharSequence data)
data
- the data to be encoded in UTF8.