public final class BufferUtils
extends Object
Buffers.| Modifier and Type | Method and Description |
|---|---|
static ByteBuf |
extractByteBufOrCreate(Buffer buffer)
Converts the passed
buffer to ByteBuf, creating a new ByteBuf instance if required. |
static ByteBufAllocator |
getByteBufAllocator(BufferAllocator allocator)
Returns the
ByteBufAllocator taking the BufferAllocator into account. |
static int |
maxUtf8Bytes(CharSequence data)
Calculate the max bytes length of UTF8 character sequence.
|
static Buffer |
newBufferFrom(ByteBuf buffer)
Return a
Buffer for the given ByteBuf. |
static ByteBuf |
toByteBuf(Buffer buffer)
Return a
ByteBuf for the given buffer. |
static ByteBuf |
toByteBufNoThrow(Buffer buffer)
Converts the passed
buffer to ByteBuf, or returns null if not possible. |
public static ByteBuf toByteBuf(Buffer buffer)
ByteBuf for the given buffer.buffer - the buffer.ByteBuf.public static ByteBuf extractByteBufOrCreate(Buffer buffer)
buffer to ByteBuf, creating a new ByteBuf instance if required.buffer - the buffer.ByteBuf.@Nullable public static 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 ByteBufAllocator getByteBufAllocator(BufferAllocator allocator)
ByteBufAllocator taking the BufferAllocator into account.allocator - the BufferAllocator that is used.ByteBufAllocator to use.public static Buffer newBufferFrom(ByteBuf buffer)
Buffer for the given ByteBuf.buffer - the buffer to wrap.public static int maxUtf8Bytes(CharSequence data)
data - the data to be encoded in UTF8.