Package io.servicetalk.buffer.api
Interface BufferAllocator
public interface BufferAllocator
An API to allocate
Buffer
s.-
Method Summary
Modifier and TypeMethodDescriptionfromAscii
(CharSequence data) Create a newBuffer
from the givenCharSequence
using Ascii encoding.fromAscii
(CharSequence data, boolean direct) Create a newBuffer
from the givenCharSequence
using Ascii encoding.fromSequence
(CharSequence data, Charset charset) fromSequence
(CharSequence data, Charset charset, boolean direct) fromUtf8
(CharSequence data) Create a newBuffer
from the givenCharSequence
using UTF-8 encoding.fromUtf8
(CharSequence data, boolean direct) Create a newBuffer
from the givenCharSequence
using UTF-8 encoding.default Buffer
Create a new buffer.default Buffer
newBuffer
(boolean direct) Create a new buffer.newBuffer
(int initialCapacity) Create a new buffer with the given initial capacity.newBuffer
(int initialCapacity, boolean direct) Create a new buffer with the given initial capacity.newBuffer
(int initialCapacity, int maxCapacity) Create a new buffer with the given initial capacity and given max capacity.Create a new composite buffer.newCompositeBuffer
(int maxComponents) Create a new composite buffer.wrap
(byte[] bytes) Create a newBuffer
that wraps the given byte array.default Buffer
wrap
(byte[] bytes, int offset, int len) Create a newBuffer
that wraps the given byte array.wrap
(ByteBuffer buffer) Create a newBuffer
that wraps the givenByteBuffer
.
-
Method Details
-
newBuffer
Create a new buffer.- Returns:
- a new buffer.
-
newBuffer
Create a new buffer.- Parameters:
direct
-true
if the buffer will be direct (off-heap),false
otherwise.- Returns:
- a new buffer.
-
newBuffer
Create a new buffer with the given initial capacity.- Parameters:
initialCapacity
- the initial capacity of the buffer.- Returns:
- a new buffer.
-
newBuffer
Create a new buffer with the given initial capacity and given max capacity.- Parameters:
initialCapacity
- the initial capacity of the buffer.maxCapacity
- the maximum capacity of the buffer.- Returns:
- a new buffer.
-
newBuffer
Create a new buffer with the given initial capacity.- Parameters:
initialCapacity
- the initial capacity of the allocated buffer.direct
-true
if the buffer will be direct (off-heap),false
otherwise.- Returns:
- a new buffer.
-
newCompositeBuffer
CompositeBuffer newCompositeBuffer()Create a new composite buffer.- Returns:
- the new buffer.
-
newCompositeBuffer
Create a new composite buffer.- Parameters:
maxComponents
- The maximum number of top levelBuffer
objects that can be contained.- Returns:
- the new buffer.
-
fromSequence
- Parameters:
data
- the sequence.charset
- the charset to use.- Returns:
- a new buffer.
-
fromSequence
- Parameters:
data
- the sequence.charset
- the charset to use.direct
-true
if the buffer will be direct (off-heap),false
otherwise.- Returns:
- a new buffer.
-
fromUtf8
Create a newBuffer
from the givenCharSequence
using UTF-8 encoding.- Parameters:
data
- the sequence.- Returns:
- a new buffer.
-
fromUtf8
Create a newBuffer
from the givenCharSequence
using UTF-8 encoding.- Parameters:
data
- the sequence.direct
-true
if the buffer will be direct (off-heap),false
otherwise.- Returns:
- a new buffer.
-
fromAscii
Create a newBuffer
from the givenCharSequence
using Ascii encoding.- Parameters:
data
- the sequence.- Returns:
- a new buffer.
-
fromAscii
Create a newBuffer
from the givenCharSequence
using Ascii encoding.- Parameters:
data
- the sequence.direct
-true
if the buffer will be direct (off-heap),false
otherwise.- Returns:
- a new buffer.
-
wrap
Create a newBuffer
that wraps the given byte array.- Parameters:
bytes
- the byte array.- Returns:
- a new buffer.
-
wrap
Create a newBuffer
that wraps the given byte array.- Parameters:
bytes
- the byte array.offset
- the offset index of the array.len
- the numbers of bytes.- Returns:
- a new buffer.
-
wrap
Create a newBuffer
that wraps the givenByteBuffer
.- Parameters:
buffer
- to wrap.- Returns:
- a new buffer.
-