Home / Class/ ByteBufInputStream Class — netty Architecture

ByteBufInputStream Class — netty Architecture

Architecture documentation for the ByteBufInputStream class in ByteBufInputStream.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  8155f4e6_8dc5_d83e_bebd_dc3672dd75bc["ByteBufInputStream"]
  3259a13f_e694_f5dd_fb22_4753316b924e["ByteBufInputStream.java"]
  8155f4e6_8dc5_d83e_bebd_dc3672dd75bc -->|defined in| 3259a13f_e694_f5dd_fb22_4753316b924e
  5ed8ec61_3f76_8f3a_a231_e611ef680345["ByteBufInputStream()"]
  8155f4e6_8dc5_d83e_bebd_dc3672dd75bc -->|method| 5ed8ec61_3f76_8f3a_a231_e611ef680345
  ee71958c_06b3_9dff_82d6_91d4dd6a9f33["readBytes()"]
  8155f4e6_8dc5_d83e_bebd_dc3672dd75bc -->|method| ee71958c_06b3_9dff_82d6_91d4dd6a9f33
  ceaccb0a_7867_cb99_6df4_4e0aa6c735f7["close()"]
  8155f4e6_8dc5_d83e_bebd_dc3672dd75bc -->|method| ceaccb0a_7867_cb99_6df4_4e0aa6c735f7
  f28937b8_813a_225f_10d0_f0055fa78b6e["available()"]
  8155f4e6_8dc5_d83e_bebd_dc3672dd75bc -->|method| f28937b8_813a_225f_10d0_f0055fa78b6e
  777abe70_a26d_9578_8eab_9751c3a2ce17["mark()"]
  8155f4e6_8dc5_d83e_bebd_dc3672dd75bc -->|method| 777abe70_a26d_9578_8eab_9751c3a2ce17
  77c1ea4a_237e_07b6_3ff5_5451a6ec2bc3["markSupported()"]
  8155f4e6_8dc5_d83e_bebd_dc3672dd75bc -->|method| 77c1ea4a_237e_07b6_3ff5_5451a6ec2bc3
  07fb0188_7ce3_d728_b8c6_fd9ded480949["read()"]
  8155f4e6_8dc5_d83e_bebd_dc3672dd75bc -->|method| 07fb0188_7ce3_d728_b8c6_fd9ded480949
  c9faedd7_dc0f_dbb6_3a10_277a50d108ca["reset()"]
  8155f4e6_8dc5_d83e_bebd_dc3672dd75bc -->|method| c9faedd7_dc0f_dbb6_3a10_277a50d108ca
  9f3d1f21_95d5_91a7_5764_16c7f0ef1ae8["skip()"]
  8155f4e6_8dc5_d83e_bebd_dc3672dd75bc -->|method| 9f3d1f21_95d5_91a7_5764_16c7f0ef1ae8
  8e58333e_6288_960c_d2ae_ad45ede01779["readBoolean()"]
  8155f4e6_8dc5_d83e_bebd_dc3672dd75bc -->|method| 8e58333e_6288_960c_d2ae_ad45ede01779
  55204a51_bff5_5755_e082_714575ba192e["readByte()"]
  8155f4e6_8dc5_d83e_bebd_dc3672dd75bc -->|method| 55204a51_bff5_5755_e082_714575ba192e
  c9691324_2e09_d25e_03be_c0feabb77f51["readChar()"]
  8155f4e6_8dc5_d83e_bebd_dc3672dd75bc -->|method| c9691324_2e09_d25e_03be_c0feabb77f51
  fe25767a_a6b8_4f75_fcb7_8d994c30fc76["readDouble()"]
  8155f4e6_8dc5_d83e_bebd_dc3672dd75bc -->|method| fe25767a_a6b8_4f75_fcb7_8d994c30fc76

Relationship Graph

Source Code

buffer/src/main/java/io/netty/buffer/ByteBufInputStream.java lines 46–327

public class ByteBufInputStream extends InputStream implements DataInput {
    private final ByteBuf buffer;
    private final int startIndex;
    private final int endIndex;
    private boolean closed;
    /**
     * To preserve backwards compatibility (which didn't transfer ownership) we support a conditional flag which
     * indicates if {@link #buffer} should be released when this {@link InputStream} is closed.
     * However in future releases ownership should always be transferred and callers of this class should call
     * {@link ReferenceCounted#retain()} if necessary.
     */
    private final boolean releaseOnClose;

    /**
     * Creates a new stream which reads data from the specified {@code buffer}
     * starting at the current {@code readerIndex} and ending at the current
     * {@code writerIndex}.
     * @param buffer The buffer which provides the content for this {@link InputStream}.
     */
    public ByteBufInputStream(ByteBuf buffer) {
        this(buffer, buffer.readableBytes());
    }

    /**
     * Creates a new stream which reads data from the specified {@code buffer}
     * starting at the current {@code readerIndex} and ending at
     * {@code readerIndex + length}.
     * @param buffer The buffer which provides the content for this {@link InputStream}.
     * @param length The length of the buffer to use for this {@link InputStream}.
     * @throws IndexOutOfBoundsException
     *         if {@code readerIndex + length} is greater than
     *            {@code writerIndex}
     */
    public ByteBufInputStream(ByteBuf buffer, int length) {
        this(buffer, length, false);
    }

    /**
     * Creates a new stream which reads data from the specified {@code buffer}
     * starting at the current {@code readerIndex} and ending at the current
     * {@code writerIndex}.
     * @param buffer The buffer which provides the content for this {@link InputStream}.
     * @param releaseOnClose {@code true} means that when {@link #close()} is called then {@link ByteBuf#release()} will
     *                       be called on {@code buffer}.
     */
    public ByteBufInputStream(ByteBuf buffer, boolean releaseOnClose) {
        this(buffer, buffer.readableBytes(), releaseOnClose);
    }

    /**
     * Creates a new stream which reads data from the specified {@code buffer}
     * starting at the current {@code readerIndex} and ending at
     * {@code readerIndex + length}.
     * @param buffer The buffer which provides the content for this {@link InputStream}.
     * @param length The length of the buffer to use for this {@link InputStream}.
     * @param releaseOnClose {@code true} means that when {@link #close()} is called then {@link ByteBuf#release()} will
     *                       be called on {@code buffer}.
     * @throws IndexOutOfBoundsException
     *         if {@code readerIndex + length} is greater than
     *            {@code writerIndex}
     */
    public ByteBufInputStream(ByteBuf buffer, int length, boolean releaseOnClose) {
        ObjectUtil.checkNotNull(buffer, "buffer");
        if (length < 0) {
            if (releaseOnClose) {
                buffer.release();
            }
            checkPositiveOrZero(length, "length");
        }
        if (length > buffer.readableBytes()) {
            if (releaseOnClose) {
                buffer.release();
            }
            throw new IndexOutOfBoundsException("Too many bytes to be read - Needs "
                    + length + ", maximum is " + buffer.readableBytes());
        }

        this.releaseOnClose = releaseOnClose;
        this.buffer = buffer;
        startIndex = buffer.readerIndex();
        endIndex = startIndex + length;

Frequently Asked Questions

What is the ByteBufInputStream class?
ByteBufInputStream is a class in the netty codebase, defined in buffer/src/main/java/io/netty/buffer/ByteBufInputStream.java.
Where is ByteBufInputStream defined?
ByteBufInputStream is defined in buffer/src/main/java/io/netty/buffer/ByteBufInputStream.java at line 46.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free