DataBuffer interface that uses a
ByteBuffer internally. with separate read and write positions.
Constructed using the DefaultDataBufferFactory.
Inspired by Netty's ByteBuf. Introduced so that non-Netty runtimes
(i.e. Servlet) do not require Netty on the classpath.
DefaultDataBufferFactory
| Modifier and Type | Class and Description |
|---|---|
| private static class | |
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private ByteBuffer | |
| private int | |
| private static final int | |
| private final DefaultDataBufferFactory | |
| private static final int | |
| private int | |
| private int |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| private static ByteBuffer | |
| public ByteBuffer | asByteBuffer()
Implements org.
Deprecated
Expose this buffer's bytes as a |
| public ByteBuffer | asByteBuffer(int
the index at which to start the byte buffer index, int the length of the returned byte buffer length)Implements org.
Deprecated
Expose a subsequence of this buffer's bytes as a |
| private void | |
| private int | |
| public int | capacity()
Implements org. Return the number of bytes that this buffer can contain. |
| public DataBuffer | capacity(int
the new capacity capacity)Implements org.
Deprecated
Set the number of bytes that this buffer can contain. |
| private void | |
| private void | |
| private void | |
| public DataBuffer | ensureWritable(int
the writable capacity to check for length)Implements org. Ensure that the current buffer has enough |
| public boolean | equals(Object
the reference object with which to compare. other)Overrides java. Indicates whether some other object is "equal to" this one. |
| public DefaultDataBufferFactory | factory()
Implements org. Return the |
| pack-priv static DefaultDataBuffer | |
| pack-priv static DefaultDataBuffer | |
| public byte | getByte(int
the index at which the byte will be read index)Implements org. Read a single byte at the given index from this data buffer. |
| public ByteBuffer | Returns: the wrapped byte bufferDirectly exposes the native |
| public int | |
| public int | indexOf(IntPredicate
the predicate to match predicate, int the index to start the search from fromIndex)Implements org. Return the index of the first byte in this buffer that matches the given predicate. |
| public int | lastIndexOf(IntPredicate
the predicate to match predicate, int the index to start the search from fromIndex)Implements org. Return the index of the last byte in this buffer that matches the given predicate. |
| public byte | read()
Implements org. Read a single byte from the current reading position from this data buffer. |
| public DefaultDataBuffer | read(byte[]
the array into which the bytes are to be written destination)Implements org. Read this buffer's data into the specified destination, starting at the current reading position of this buffer. |
| public DefaultDataBuffer | read(byte[]
the array into which the bytes are to be written destination, int the index within offset, int destination of the first byte to be writtenthe maximum number of bytes to be written in length)destinationImplements org. Read at most |
| public DataBuffer. | readableByteBuffers()
Implements org. Returns a closeable iterator over each |
| public int | readableByteCount()
Implements org. Return the number of bytes that can be read from this data buffer. |
| public int | readPosition()
Implements org. Return the position from which this buffer will read. |
| public DefaultDataBuffer | readPosition(int
the new read position readPosition)Implements org. Set the position from which this buffer will read. |
| private void | |
| private void | |
| public DefaultDataBuffer | slice(int
the index at which to start the slice index, int the length of the slice length)Implements org.
Deprecated
Create a new |
| public DataBuffer | split(int
the index at which it should be split index)Implements org. Splits this data buffer into two at the given index. |
| public ByteBuffer | toByteBuffer(int index, int length)
Implements org.
Deprecated
Returns a |
| public void | toByteBuffer(int
the position of this data buffer from where copying should start srcPos, ByteBuffer the destination byte buffer dest, int the position in destPos, int dest to where copying should startthe amount of data to copy length)Implements org. Copies the given length from this data buffer into the given destination
|
| public String | toString(int
the index at which to start the string index, int the number of bytes to use for the string length, Charset the charset to use charset)Implements org. Return a part of this buffer's data as a String using the specified charset. |
| public String | |
| public DataBuffer. | writableByteBuffers()
Implements org. Returns a closeable iterator over each |
| public int | writableByteCount()
Implements org. Return the number of bytes that can be written to this data buffer. |
| public DefaultDataBuffer | write(byte
the byte to be written b)Implements org. Write a single byte into this buffer at the current writing position. |
| public DefaultDataBuffer | write(byte[]
the bytes to be written into this buffer source)Implements org. Write the given source into this buffer, starting at the current writing position of this buffer. |
| public DefaultDataBuffer | write(byte[]
the bytes to be written into this buffer source, int the index within offset, int source to start writing fromthe maximum number of bytes to be written from length)sourceImplements org. Write at most |
| public DefaultDataBuffer | write(DataBuffer...
the byte buffers to write into this buffer dataBuffers)Implements org. Write one or more |
| public DefaultDataBuffer | write(ByteBuffer...
the byte buffers to write into this buffer buffers)Implements org. Write one or more |
| private void | |
| public int | writePosition()
Implements org. Return the position to which this buffer will write. |
| public DefaultDataBuffer | writePosition(int
the new write position writePosition)Implements org. Set the position to which this buffer will write. |
| byteBuffer | back to summary |
|---|---|
| private ByteBuffer byteBuffer | |
| capacity | back to summary |
|---|---|
| private int capacity | |
| CAPACITY_THRESHOLD | back to summary |
|---|---|
| private static final int CAPACITY_THRESHOLD | |
| dataBufferFactory | back to summary |
|---|---|
| private final DefaultDataBufferFactory dataBufferFactory | |
| MAX_CAPACITY | back to summary |
|---|---|
| private static final int MAX_CAPACITY | |
| readPosition | back to summary |
|---|---|
| private int readPosition | |
| writePosition | back to summary |
|---|---|
| private int writePosition | |
| DefaultDataBuffer | back to summary |
|---|---|
| private DefaultDataBuffer(DefaultDataBufferFactory dataBufferFactory, ByteBuffer byteBuffer) | |
| allocate | back to summary |
|---|---|
| private static ByteBuffer allocate(int capacity, boolean direct) | |
| asByteBuffer | back to summary |
|---|---|
| public ByteBuffer asByteBuffer() Implements org. Doc from org. Deprecated
Expose this buffer's bytes as a
| |
| asByteBuffer | back to summary |
|---|---|
| public ByteBuffer asByteBuffer(int index, int length) Implements org. Doc from org. Deprecated
Expose a subsequence of this buffer's bytes as a
| |
| assertIndex | back to summary |
|---|---|
| private void assertIndex(boolean expression, String format, Object... args) | |
| calculateCapacity | back to summary |
|---|---|
| private int calculateCapacity(int neededCapacity) Calculate the capacity of the buffer. | |
| capacity | back to summary |
|---|---|
| public int capacity() Implements org. Doc from org. Return the number of bytes that this buffer can contain.
| |
| capacity | back to summary |
|---|---|
| public DataBuffer capacity(int capacity) Implements org. Doc from org. Deprecated
Set the number of bytes that this buffer can contain. If the new capacity is lower than the current capacity, the contents of this buffer will be truncated. If the new capacity is higher than the current capacity, it will be expanded.
| |
| checkIndex | back to summary |
|---|---|
| private void checkIndex(int index, int length) | |
| checkIndex | back to summary |
|---|---|
| private void checkIndex(int index) | |
| checkLength | back to summary |
|---|---|
| private void checkLength(int length) | |
| ensureWritable | back to summary |
|---|---|
| public DataBuffer ensureWritable(int length) Implements org. Doc from org. Ensure that the current buffer has enough
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object other) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| factory | back to summary |
|---|---|
| public DefaultDataBufferFactory factory() Implements org. Doc from org. Return the
| |
| fromEmptyByteBuffer | back to summary |
|---|---|
| pack-priv static DefaultDataBuffer fromEmptyByteBuffer(DefaultDataBufferFactory dataBufferFactory, ByteBuffer byteBuffer) | |
| fromFilledByteBuffer | back to summary |
|---|---|
| pack-priv static DefaultDataBuffer fromFilledByteBuffer(DefaultDataBufferFactory dataBufferFactory, ByteBuffer byteBuffer) | |
| getByte | back to summary |
|---|---|
| public byte getByte(int index) Implements org. Doc from org. Read a single byte at the given index from this data buffer.
| |
| getNativeBuffer | back to summary |
|---|---|
| public ByteBuffer getNativeBuffer() Directly exposes the native
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| indexOf | back to summary |
|---|---|
| public int indexOf(IntPredicate predicate, int fromIndex) Implements org. Doc from org. Return the index of the first byte in this buffer that matches the given predicate.
| |
| lastIndexOf | back to summary |
|---|---|
| public int lastIndexOf(IntPredicate predicate, int fromIndex) Implements org. Doc from org. Return the index of the last byte in this buffer that matches the given predicate.
| |
| read | back to summary |
|---|---|
| public byte read() Implements org. Doc from org. Read a single byte from the current reading position from this data buffer.
| |
| read | back to summary |
|---|---|
| public DefaultDataBuffer read(byte[] destination) Implements org. Doc from org. Read this buffer's data into the specified destination, starting at the current reading position of this buffer.
| |
| read | back to summary |
|---|---|
| public DefaultDataBuffer read(byte[] destination, int offset, int length) Implements org. Doc from org. Read at most
| |
| readableByteBuffers | back to summary |
|---|---|
| public DataBuffer. Implements org. Doc from org. Returns a closeable iterator over each Note that the returned iterator must be used in a try-with-resources clause or explicitly closed.
| |
| readableByteCount | back to summary |
|---|---|
| public int readableByteCount() Implements org. Doc from org. Return the number of bytes that can be read from this data buffer.
| |
| readPosition | back to summary |
|---|---|
| public int readPosition() Implements org. Doc from org. Return the position from which this buffer will read.
| |
| readPosition | back to summary |
|---|---|
| public DefaultDataBuffer readPosition(int readPosition) Implements org. Doc from org. Set the position from which this buffer will read.
| |
| setCapacity | back to summary |
|---|---|
| private void setCapacity(int newCapacity) | |
| setNativeBuffer | back to summary |
|---|---|
| private void setNativeBuffer(ByteBuffer byteBuffer) | |
| slice | back to summary |
|---|---|
| public DefaultDataBuffer slice(int index, int length) Implements org. Doc from org. Deprecated
Create a new Note that this method will not call
| |
| split | back to summary |
|---|---|
| public DataBuffer split(int index) Implements org. Doc from org. Splits this data buffer into two at the given index. Data that precedes the The read and
write position of the returned buffer are
truncated to fit within the buffers capacity if
necessary. The positions of this buffer are set to
| |
| toByteBuffer | back to summary |
|---|---|
| public ByteBuffer toByteBuffer(int index, int length) Implements org. Doc from org. Deprecated
Returns a
| |
| toByteBuffer | back to summary |
|---|---|
| public void toByteBuffer(int srcPos, ByteBuffer dest, int destPos, int length) Implements org. Doc from org. Copies the given length from this data buffer into the given destination
| |
| toString | back to summary |
|---|---|
| public String toString(int index, int length, Charset charset) Implements org. Doc from org. Return a part of this buffer's data as a String using the specified charset. | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |
| writableByteBuffers | back to summary |
|---|---|
| public DataBuffer. Implements org. Doc from org. Returns a closeable iterator over each Note that the returned iterator must be used in a try-with-resources clause or explicitly closed.
| |
| writableByteCount | back to summary |
|---|---|
| public int writableByteCount() Implements org. Doc from org. Return the number of bytes that can be written to this data buffer.
| |
| write | back to summary |
|---|---|
| public DefaultDataBuffer write(byte b) Implements org. Doc from org. Write a single byte into this buffer at the current writing position.
| |
| write | back to summary |
|---|---|
| public DefaultDataBuffer write(byte[] source) Implements org. Doc from org. Write the given source into this buffer, starting at the current writing position of this buffer.
| |
| write | back to summary |
|---|---|
| public DefaultDataBuffer write(byte[] source, int offset, int length) Implements org. Doc from org. Write at most
| |
| write | back to summary |
|---|---|
| public DefaultDataBuffer write(DataBuffer... dataBuffers) Implements org. Doc from org. Write one or more
| |
| write | back to summary |
|---|---|
| public DefaultDataBuffer write(ByteBuffer... buffers) Implements org. Doc from org. Write one or more
| |
| write | back to summary |
|---|---|
| private void write(ByteBuffer source) | |
| writePosition | back to summary |
|---|---|
| public int writePosition() Implements org. Doc from org. Return the position to which this buffer will write.
| |
| writePosition | back to summary |
|---|---|
| public DefaultDataBuffer writePosition(int writePosition) Implements org. Doc from org. Set the position to which this buffer will write.
| |
| Modifier and Type | Field and Description |
|---|---|
| private final ByteBuffer | |
| private boolean |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | close()
Implements org. Closes this stream and releases any system resources associated with it. |
| public boolean | |
| public ByteBuffer |
| buffer | back to summary |
|---|---|
| private final ByteBuffer buffer | |
| hasNext | back to summary |
|---|---|
| private boolean hasNext | |
| ByteBufferIterator | back to summary |
|---|---|
| public ByteBufferIterator(ByteBuffer buffer) | |
| close | back to summary |
|---|---|
| public void close() Implements org. Doc from java. Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect. As noted in
| |
| hasNext | back to summary |
|---|---|
| public boolean hasNext() Implements java. Doc from java. Returns
| |
| next | back to summary |
|---|---|
| public ByteBuffer next() Implements java. Doc from java. Returns the next element in the iteration.
| |
| Access | Constructor and Description |
|---|---|
| pack-priv | SlicedDefaultDataBuffer(ByteBuffer byteBuffer, DefaultDataBufferFactory dataBufferFactory, int length)
|
| Modifier and Type | Method and Description |
|---|---|
| public DefaultDataBuffer | capacity(int
the new capacity newCapacity)Overrides org. Implements org. Set the number of bytes that this buffer can contain. |
| SlicedDefaultDataBuffer | back to summary |
|---|---|
| pack-priv SlicedDefaultDataBuffer(ByteBuffer byteBuffer, DefaultDataBufferFactory dataBufferFactory, int length) | |
| capacity | back to summary |
|---|---|
| public DefaultDataBuffer capacity(int newCapacity) Overrides org. Implements org. Doc from org. Set the number of bytes that this buffer can contain. If the new capacity is lower than the current capacity, the contents of this buffer will be truncated. If the new capacity is higher than the current capacity, it will be expanded.
| |