@Test public void testAddBuffer() { DynamicCompositeByteBuf compositeByteBuf = new DynamicCompositeByteBuf(); Assert.assertTrue(compositeByteBuf.readableBytes() == 0); ByteBuf byteBuf1 = Unpooled.wrappedBuffer("hello".getBytes()); Assert.assertTrue(byteBuf1.refCnt() == 1); compositeByteBuf.addBuffer(byteBuf1); Assert.assertTrue(compositeByteBuf.readableBytes() == byteBuf1.readableBytes()); Assert.assertTrue(byteBuf1.refCnt() == 1); ByteBuf byteBuf2 = Unpooled.wrappedBuffer("world".getBytes()); compositeByteBuf.addBuffer(byteBuf2); Assert.assertTrue(compositeByteBuf.readableBytes() == byteBuf1.readableBytes() + byteBuf2.readableBytes()); compositeByteBuf.release(); Assert.assertTrue(byteBuf1.refCnt() == 0); }
public void addBuffer(ByteBuf buffer) { if (buffer != null) { int bufLen = buffer.readableBytes(); if (bufLen > 0) { buffers.add(buffer); readableBytes += bufLen; } } }
DynamicCompositeByteBuf { public void addBuffer(ByteBuf buffer) { if (buffer != null) { int bufLen = buffer.readableBytes(); if (bufLen > 0) { buffers.add(buffer); readableBytes += bufLen; } } } }
DynamicCompositeByteBuf { public void addBuffer(ByteBuf buffer) { if (buffer != null) { int bufLen = buffer.readableBytes(); if (bufLen > 0) { buffers.add(buffer); readableBytes += bufLen; } } } DynamicCompositeByteBuf();  DynamicCompositeByteBuf(int capacity);  DynamicCompositeByteBuf(ByteBuf buf);  DynamicCompositeByteBuf(ByteBuf[] bufs, int offset, int len); }
DynamicCompositeByteBuf { public void addBuffer(ByteBuf buffer) { if (buffer != null) { int bufLen = buffer.readableBytes(); if (bufLen > 0) { buffers.add(buffer); readableBytes += bufLen; } } } DynamicCompositeByteBuf();  DynamicCompositeByteBuf(int capacity);  DynamicCompositeByteBuf(ByteBuf buf);  DynamicCompositeByteBuf(ByteBuf[] bufs, int offset, int len); int readableBytes(); boolean isEmpty(); boolean hasArray(); byte[] array(); int arrayOffset(); int readerIndex(); boolean isReadable(); ByteBuf nettyByteBuf(); void addBuffer(ByteBuf buffer); ByteBuf readRetainedSlice(int length); ByteBuf retainedSlice(int length); void skipBytes(int length); DynamicCompositeByteBuf readBytes(byte[] dst); DynamicCompositeByteBuf readBytes(byte[] dst, int dstIndex, int length); byte readByte(); short readUnsignedByte(); short readShort(); short readShortLE(); int readUnsignedShort(); int readUnsignedShortLE(); int readInt(); int readIntLE(); long readLong(); long readLongLE(); char readChar(); float readFloat(); float readFloatLE(); double readDouble(); double readDoubleLE(); ByteOrder order(); void release(); @Override String toString(); }
DynamicCompositeByteBuf { public void addBuffer(ByteBuf buffer) { if (buffer != null) { int bufLen = buffer.readableBytes(); if (bufLen > 0) { buffers.add(buffer); readableBytes += bufLen; } } } DynamicCompositeByteBuf();  DynamicCompositeByteBuf(int capacity);  DynamicCompositeByteBuf(ByteBuf buf);  DynamicCompositeByteBuf(ByteBuf[] bufs, int offset, int len); int readableBytes(); boolean isEmpty(); boolean hasArray(); byte[] array(); int arrayOffset(); int readerIndex(); boolean isReadable(); ByteBuf nettyByteBuf(); void addBuffer(ByteBuf buffer); ByteBuf readRetainedSlice(int length); ByteBuf retainedSlice(int length); void skipBytes(int length); DynamicCompositeByteBuf readBytes(byte[] dst); DynamicCompositeByteBuf readBytes(byte[] dst, int dstIndex, int length); byte readByte(); short readUnsignedByte(); short readShort(); short readShortLE(); int readUnsignedShort(); int readUnsignedShortLE(); int readInt(); int readIntLE(); long readLong(); long readLongLE(); char readChar(); float readFloat(); float readFloatLE(); double readDouble(); double readDoubleLE(); ByteOrder order(); void release(); @Override String toString();  }