|
|
|
@ -25,10 +25,10 @@ import java.util.function.IntPredicate; |
|
|
|
* Basic abstraction over byte buffers. |
|
|
|
* Basic abstraction over byte buffers. |
|
|
|
* |
|
|
|
* |
|
|
|
* <p>{@code DataBuffer}s has a separate {@linkplain #readPosition() read} and |
|
|
|
* <p>{@code DataBuffer}s has a separate {@linkplain #readPosition() read} and |
|
|
|
* {@linkplain #writePosition() write} position, as opposed to {@code ByteBuffer}'s single |
|
|
|
* {@linkplain #writePosition() write} position, as opposed to {@code ByteBuffer}'s |
|
|
|
* {@linkplain ByteBuffer#position() position}. As such, the {@code DataBuffer} does not require |
|
|
|
* single {@linkplain ByteBuffer#position() position}. As such, the {@code DataBuffer} |
|
|
|
* a {@linkplain ByteBuffer#flip() flip} to read after writing. In general, the following invariant |
|
|
|
* does not require a {@linkplain ByteBuffer#flip() flip} to read after writing. In general, |
|
|
|
* holds for the read and write positions, and the capacity: |
|
|
|
* the following invariant holds for the read and write positions, and the capacity: |
|
|
|
* |
|
|
|
* |
|
|
|
* <blockquote> |
|
|
|
* <blockquote> |
|
|
|
* <tt>0</tt> <tt><=</tt> |
|
|
|
* <tt>0</tt> <tt><=</tt> |
|
|
|
@ -41,8 +41,8 @@ import java.util.function.IntPredicate; |
|
|
|
* similar to {@code StringBuilder}. |
|
|
|
* similar to {@code StringBuilder}. |
|
|
|
* |
|
|
|
* |
|
|
|
* <p>The main purpose of the {@code DataBuffer} abstraction is to provide a convenient wrapper |
|
|
|
* <p>The main purpose of the {@code DataBuffer} abstraction is to provide a convenient wrapper |
|
|
|
* around {@link ByteBuffer} that is similar to Netty's {@link io.netty.buffer.ByteBuf}, but that |
|
|
|
* around {@link ByteBuffer} which is similar to Netty's {@link io.netty.buffer.ByteBuf} but |
|
|
|
* can also be used on non-Netty platforms (i.e. Servlet). |
|
|
|
* can also be used on non-Netty platforms (i.e. Servlet containers). |
|
|
|
* |
|
|
|
* |
|
|
|
* @author Arjen Poutsma |
|
|
|
* @author Arjen Poutsma |
|
|
|
* @since 5.0 |
|
|
|
* @since 5.0 |
|
|
|
@ -239,8 +239,8 @@ public interface DataBuffer { |
|
|
|
ByteBuffer asByteBuffer(); |
|
|
|
ByteBuffer asByteBuffer(); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Expose a subsequence of this buffer's bytes as a {@link ByteBuffer}. Data between this |
|
|
|
* Expose a subsequence of this buffer's bytes as a {@link ByteBuffer}. Data between |
|
|
|
* {@code DataBuffer} and the returned {@code ByteBuffer} is shared; though |
|
|
|
* this {@code DataBuffer} and the returned {@code ByteBuffer} is shared; though |
|
|
|
* changes in the returned buffer's {@linkplain ByteBuffer#position() position} |
|
|
|
* changes in the returned buffer's {@linkplain ByteBuffer#position() position} |
|
|
|
* will not be reflected in the reading nor writing position of this data buffer. |
|
|
|
* will not be reflected in the reading nor writing position of this data buffer. |
|
|
|
* @param index the index at which to start the byte buffer |
|
|
|
* @param index the index at which to start the byte buffer |
|
|
|
@ -253,8 +253,8 @@ public interface DataBuffer { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Expose this buffer's data as an {@link InputStream}. Both data and read position are |
|
|
|
* Expose this buffer's data as an {@link InputStream}. Both data and read position are |
|
|
|
* shared between the returned stream and this data buffer. The underlying buffer will |
|
|
|
* shared between the returned stream and this data buffer. The underlying buffer will |
|
|
|
* <strong>not</strong> be {@linkplain DataBufferUtils#release(DataBuffer) released} when the |
|
|
|
* <strong>not</strong> be {@linkplain DataBufferUtils#release(DataBuffer) released} |
|
|
|
* input stream is {@linkplain InputStream#close() closed}. |
|
|
|
* when the input stream is {@linkplain InputStream#close() closed}. |
|
|
|
* @return this data buffer as an input stream |
|
|
|
* @return this data buffer as an input stream |
|
|
|
* @see #asInputStream(boolean) |
|
|
|
* @see #asInputStream(boolean) |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|