public abstract class BytesInput extends Object
| Constructor and Description |
|---|
BytesInput() |
| Modifier and Type | Method and Description |
|---|---|
static BytesInput |
concat(BytesInput... inputs)
logically concatenate the provided inputs
|
static BytesInput |
concat(List<BytesInput> inputs)
logically concatenate the provided inputs
|
BytesInput |
copy(ByteBufferAllocator allocator,
Consumer<ByteBuffer> callback)
Copies the content of this
BytesInput object to a newly created ByteBuffer and returns it wrapped
in a BytesInput object. |
BytesInput |
copy(ByteBufferReleaser releaser)
Similar to
copy(ByteBufferAllocator, Consumer) where the allocator and the callback are in the specified
ByteBufferReleaser. |
static BytesInput |
copy(BytesInput bytesInput)
Deprecated.
Use
copy(ByteBufferAllocator, Consumer) instead |
static BytesInput |
empty() |
static BytesInput |
from(byte[] in) |
static BytesInput |
from(byte[] in,
int offset,
int length) |
static BytesInput |
from(ByteArrayOutputStream baos) |
static BytesInput |
from(ByteBuffer... buffers) |
static BytesInput |
from(ByteBuffer buffer,
int offset,
int length)
Deprecated.
Will be removed in 2.0.0
|
static BytesInput |
from(CapacityByteArrayOutputStream arrayOut) |
static BytesInput |
from(InputStream in,
int bytes) |
static BytesInput |
from(List<ByteBuffer> buffers) |
static BytesInput |
fromInt(int intValue) |
static BytesInput |
fromUnsignedVarInt(int intValue) |
static BytesInput |
fromUnsignedVarLong(long longValue) |
static BytesInput |
fromZigZagVarInt(int intValue) |
static BytesInput |
fromZigZagVarLong(long longValue) |
abstract long |
size() |
byte[] |
toByteArray()
Deprecated.
|
ByteBuffer |
toByteBuffer()
Deprecated.
|
ByteBuffer |
toByteBuffer(ByteBufferAllocator allocator,
Consumer<ByteBuffer> callback)
Returns a
ByteBuffer object referencing the data behind this BytesInput object. |
ByteBuffer |
toByteBuffer(ByteBufferReleaser releaser)
Similar to
toByteBuffer(ByteBufferAllocator, Consumer) where the allocator and the callback are in the
specified ByteBufferReleaser. |
ByteBufferInputStream |
toInputStream() |
abstract void |
writeAllTo(OutputStream out)
writes the bytes into a stream
|
public static BytesInput concat(BytesInput... inputs)
inputs - the inputs to concatenatepublic static BytesInput concat(List<BytesInput> inputs)
inputs - the inputs to concatenatepublic static BytesInput from(InputStream in, int bytes)
in - an input streambytes - number of bytes to read@Deprecated public static BytesInput from(ByteBuffer buffer, int offset, int length)
buffer - length - number of bytes to readpublic static BytesInput from(ByteBuffer... buffers)
buffers - an array of byte bufferspublic static BytesInput from(List<ByteBuffer> buffers)
buffers - a list of byte bufferspublic static BytesInput from(byte[] in)
in - a byte arraypublic static BytesInput from(byte[] in, int offset, int length)
public static BytesInput fromInt(int intValue)
intValue - the int to writepublic static BytesInput fromUnsignedVarInt(int intValue)
intValue - the int to writepublic static BytesInput fromZigZagVarInt(int intValue)
intValue - the int to writepublic static BytesInput fromUnsignedVarLong(long longValue)
longValue - the long to writepublic static BytesInput fromZigZagVarLong(long longValue)
longValue - the long to writepublic static BytesInput from(CapacityByteArrayOutputStream arrayOut)
arrayOut - a capacity byte array output stream to wrap into a BytesInputpublic static BytesInput from(ByteArrayOutputStream baos)
baos - - stream to wrap into a BytesInputpublic static BytesInput empty()
@Deprecated public static BytesInput copy(BytesInput bytesInput) throws IOException
copy(ByteBufferAllocator, Consumer) insteadbytesInput - a BytesInputIOException - if there is an exception when reading bytes from the BytesInputpublic abstract void writeAllTo(OutputStream out) throws IOException
out - an output streamIOException - if there is an exception writing@Deprecated public byte[] toByteArray() throws IOException
toByteBuffer(ByteBufferAllocator, Consumer)IOException - if there is an exception reading@Deprecated public ByteBuffer toByteBuffer() throws IOException
toByteBuffer(ByteBufferAllocator, Consumer)IOException - if there is an exception readingpublic BytesInput copy(ByteBufferAllocator allocator, Consumer<ByteBuffer> callback)
BytesInput object to a newly created ByteBuffer and returns it wrapped
in a BytesInput object.
The data content shall be able to be fit in a ByteBuffer object! (In case of the size of
this BytesInput object cannot fit in an int, an ArithmeticException will be thrown. The
allocator might throw an OutOfMemoryError if it is unable to allocate the required
ByteBuffer.)allocator - the allocator to be used for creating the new ByteBuffer objectcallback - the callback called with the newly created ByteBuffer object; to be used for make it
released at the proper timeBytesInput object wrapping the copied content of the specified onepublic BytesInput copy(ByteBufferReleaser releaser)
copy(ByteBufferAllocator, Consumer) where the allocator and the callback are in the specified
ByteBufferReleaser.public ByteBuffer toByteBuffer(ByteBufferAllocator allocator, Consumer<ByteBuffer> callback)
ByteBuffer object referencing the data behind this BytesInput object. It may create a new
ByteBuffer object if this BytesInput is not backed by a single ByteBuffer. In the latter
case the specified ByteBufferAllocator object will be used. In case of allocation the specified callback
will be invoked so the release of the newly allocated ByteBuffer object can be released at a proper time.
The data content shall be able to be fit in a ByteBuffer object! (In case of the size of
this BytesInput object cannot fit in an int, an ArithmeticException will be thrown. The
allocator might throw an OutOfMemoryError if it is unable to allocate the required
ByteBuffer.)allocator - the ByteBufferAllocator to be used for potentially allocating a new ByteBuffer
objectcallback - the callback to be called with the new ByteBuffer object potentially allocatedByteBuffer object with the data content of this BytesInput object. (Might be a copy of
the content or directly referencing the same memory as this BytesInput object.)public ByteBuffer toByteBuffer(ByteBufferReleaser releaser)
toByteBuffer(ByteBufferAllocator, Consumer) where the allocator and the callback are in the
specified ByteBufferReleaser.public ByteBufferInputStream toInputStream() throws IOException
IOException - if there is an exception readingpublic abstract long size()
Copyright © 2023 The Apache Software Foundation. All rights reserved.