Home / Class/ TestGatheringByteChannel Class — netty Architecture

TestGatheringByteChannel Class — netty Architecture

Architecture documentation for the TestGatheringByteChannel class in AbstractByteBufTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  7114d0f5_aa45_6f9d_67c8_4f23e7cb150c["TestGatheringByteChannel"]
  53d91bbd_e169_0486_4b8f_b7350f1cb9da["AbstractByteBufTest.java"]
  7114d0f5_aa45_6f9d_67c8_4f23e7cb150c -->|defined in| 53d91bbd_e169_0486_4b8f_b7350f1cb9da
  59ba4968_9c0d_bad7_eec5_7f3db0ff59a4["TestGatheringByteChannel()"]
  7114d0f5_aa45_6f9d_67c8_4f23e7cb150c -->|method| 59ba4968_9c0d_bad7_eec5_7f3db0ff59a4
  44bc52c8_9e37_f288_9818_974c89b1a5e6["write()"]
  7114d0f5_aa45_6f9d_67c8_4f23e7cb150c -->|method| 44bc52c8_9e37_f288_9818_974c89b1a5e6
  9a290f55_3f9c_17fd_7d95_6420629a39fa["isOpen()"]
  7114d0f5_aa45_6f9d_67c8_4f23e7cb150c -->|method| 9a290f55_3f9c_17fd_7d95_6420629a39fa
  3b376070_a080_cb6d_9a78_e8acbbdd5c2c["close()"]
  7114d0f5_aa45_6f9d_67c8_4f23e7cb150c -->|method| 3b376070_a080_cb6d_9a78_e8acbbdd5c2c
  db8583f4_ff68_4133_f18f_f472723e565e["writtenBytes()"]
  7114d0f5_aa45_6f9d_67c8_4f23e7cb150c -->|method| db8583f4_ff68_4133_f18f_f472723e565e

Relationship Graph

Source Code

buffer/src/test/java/io/netty/buffer/AbstractByteBufTest.java lines 6022–6075

    static final class TestGatheringByteChannel implements GatheringByteChannel {
        private final ByteArrayOutputStream out = new ByteArrayOutputStream();
        private final WritableByteChannel channel = Channels.newChannel(out);
        private final int limit;
        TestGatheringByteChannel(int limit) {
            this.limit = limit;
        }

        TestGatheringByteChannel() {
            this(Integer.MAX_VALUE);
        }

        @Override
        public long write(ByteBuffer[] srcs, int offset, int length) throws IOException {
            long written = 0;
            for (; offset < length; offset++) {
                written += write(srcs[offset]);
                if (written >= limit) {
                    break;
                }
            }
            return written;
        }

        @Override
        public long write(ByteBuffer[] srcs) throws IOException {
            return write(srcs, 0, srcs.length);
        }

        @Override
        public int write(ByteBuffer src) throws IOException {
            int oldLimit = src.limit();
            if (limit < src.remaining()) {
                src.limit(src.position() + limit);
            }
            int w = channel.write(src);
            src.limit(oldLimit);
            return w;
        }

        @Override
        public boolean isOpen() {
            return channel.isOpen();
        }

        @Override
        public void close() throws IOException {
            channel.close();
        }

        public byte[] writtenBytes() {
            return out.toByteArray();
        }
    }

Frequently Asked Questions

What is the TestGatheringByteChannel class?
TestGatheringByteChannel is a class in the netty codebase, defined in buffer/src/test/java/io/netty/buffer/AbstractByteBufTest.java.
Where is TestGatheringByteChannel defined?
TestGatheringByteChannel is defined in buffer/src/test/java/io/netty/buffer/AbstractByteBufTest.java at line 6022.

Analyze Your Own Codebase

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

Try Supermodel Free