public interface DataBuffer
Modifier and Type | Method and Description |
---|---|
java.nio.ByteBuffer |
asByteBuffer()
Expose this buffer's bytes as a
ByteBuffer . |
java.io.InputStream |
asInputStream()
Expose this buffer's data as an
InputStream . |
java.io.OutputStream |
asOutputStream()
Expose this buffer's data as an
OutputStream . |
DataBufferFactory |
factory()
Return the
DataBufferFactory that created this buffer. |
int |
indexOf(java.util.function.IntPredicate predicate,
int fromIndex)
Return the index of the first byte in this buffer that matches the given
predicate.
|
int |
lastIndexOf(java.util.function.IntPredicate predicate,
int fromIndex)
Return the index of the last byte in this buffer that matches the given
predicate.
|
byte |
read()
Read a single byte from the current reading position of this data buffer.
|
DataBuffer |
read(byte[] destination)
Read this buffer's data into the specified destination, starting at the current
reading position of this buffer.
|
DataBuffer |
read(byte[] destination,
int offset,
int length)
Read at most
length bytes of this buffer into the specified destination,
starting at the current reading position of this buffer. |
int |
readableByteCount()
Return the number of bytes that can be read from this data buffer.
|
DataBuffer |
slice(int index,
int length)
Create a new
DataBuffer whose contents is a shared subsequence of this
data buffer's content. |
DataBuffer |
write(byte b)
Write a single byte into this buffer at the current writing position.
|
DataBuffer |
write(byte[] source)
Write the given source into this buffer, startin at the current writing position
of this buffer.
|
DataBuffer |
write(byte[] source,
int offset,
int length)
Write at most
length bytes of the given source into this buffer, starting
at the current writing position of this buffer. |
DataBuffer |
write(java.nio.ByteBuffer... buffers)
Write one or more
ByteBuffer to this buffer, starting at the current
writing position. |
DataBuffer |
write(DataBuffer... buffers)
Write one or more
DataBuffer s to this buffer, starting at the current
writing position. |
DataBufferFactory factory()
DataBufferFactory
that created this buffer.int indexOf(java.util.function.IntPredicate predicate, int fromIndex)
predicate
- the predicate to matchfromIndex
- the index to start the search frompredicate
; or -1
if none matchint lastIndexOf(java.util.function.IntPredicate predicate, int fromIndex)
predicate
- the predicate to matchfromIndex
- the index to start the search frompredicate
; or -1
if none matchint readableByteCount()
byte read()
DataBuffer read(byte[] destination)
destination
- the array into which the bytes are to be writtenDataBuffer read(byte[] destination, int offset, int length)
length
bytes of this buffer into the specified destination,
starting at the current reading position of this buffer.destination
- the array into which the bytes are to be writtenoffset
- the index within destination
of the first byte to be writtenlength
- the maximum number of bytes to be written in destination
DataBuffer write(byte b)
b
- the byte to be writtenDataBuffer write(byte[] source)
source
- the bytes to be written into this bufferDataBuffer write(byte[] source, int offset, int length)
length
bytes of the given source into this buffer, starting
at the current writing position of this buffer.source
- the bytes to be written into this bufferoffset
- the index withing source
to start writing fromlength
- the maximum number of bytes to be written from source
DataBuffer write(DataBuffer... buffers)
DataBuffer
s to this buffer, starting at the current
writing position.buffers
- the byte buffers to write into this bufferDataBuffer write(java.nio.ByteBuffer... buffers)
ByteBuffer
to this buffer, starting at the current
writing position.buffers
- the byte buffers to write into this bufferDataBuffer slice(int index, int length)
DataBuffer
whose contents is a shared subsequence of this
data buffer's content. Data between this data buffer and the returned buffer is
shared; though changes in the returned buffer's position will not be reflected
in the reading nor writing position of this data buffer.index
- the index at which to start the slicelength
- the length of the slicejava.nio.ByteBuffer asByteBuffer()
ByteBuffer
. Data between this
DataBuffer
and the returned ByteBuffer
is shared; though
changes in the returned buffer's position
will not be reflected in the reading nor writing position of this data buffer.java.io.InputStream asInputStream()
InputStream
. Both data and position are
shared between the returned stream and this data buffer.java.io.OutputStream asOutputStream()
OutputStream
. Both data and position are
shared between the returned stream and this data buffer.