@Test public void testReadInt() { DynamicCompositeByteBuf compositeByteBuf = new DynamicCompositeByteBuf(); ByteBuf buf = Unpooled.buffer(8); buf.writeInt(1); buf.writeInt(2); compositeByteBuf.addBuffer(buf); Assert.assertTrue(compositeByteBuf.readInt() == 1); Assert.assertTrue(compositeByteBuf.readInt() == 2); }
public int readInt() { checkReadableBytes0(4); ByteBuf first = buffers.peek(); int firstLen = first.readableBytes(); if (firstLen >= 4) { int res = first.readInt(); readableBytes -= 4; if (firstLen == 4) { buffers.removeFirst().release(); } return res; } else if (order() == ByteOrder.BIG_ENDIAN) { return (readShort() & 0xffff) << 16 | readShort() & 0xffff; } else { return readShort() & 0xFFFF | (readShort() & 0xFFFF) << 16; } }
DynamicCompositeByteBuf { public int readInt() { checkReadableBytes0(4); ByteBuf first = buffers.peek(); int firstLen = first.readableBytes(); if (firstLen >= 4) { int res = first.readInt(); readableBytes -= 4; if (firstLen == 4) { buffers.removeFirst().release(); } return res; } else if (order() == ByteOrder.BIG_ENDIAN) { return (readShort() & 0xffff) << 16 | readShort() & 0xffff; } else { return readShort() & 0xFFFF | (readShort() & 0xFFFF) << 16; } } }
DynamicCompositeByteBuf { public int readInt() { checkReadableBytes0(4); ByteBuf first = buffers.peek(); int firstLen = first.readableBytes(); if (firstLen >= 4) { int res = first.readInt(); readableBytes -= 4; if (firstLen == 4) { buffers.removeFirst().release(); } return res; } else if (order() == ByteOrder.BIG_ENDIAN) { return (readShort() & 0xffff) << 16 | readShort() & 0xffff; } else { return readShort() & 0xFFFF | (readShort() & 0xFFFF) << 16; } } DynamicCompositeByteBuf();  DynamicCompositeByteBuf(int capacity);  DynamicCompositeByteBuf(ByteBuf buf);  DynamicCompositeByteBuf(ByteBuf[] bufs, int offset, int len); }
DynamicCompositeByteBuf { public int readInt() { checkReadableBytes0(4); ByteBuf first = buffers.peek(); int firstLen = first.readableBytes(); if (firstLen >= 4) { int res = first.readInt(); readableBytes -= 4; if (firstLen == 4) { buffers.removeFirst().release(); } return res; } else if (order() == ByteOrder.BIG_ENDIAN) { return (readShort() & 0xffff) << 16 | readShort() & 0xffff; } else { return readShort() & 0xFFFF | (readShort() & 0xFFFF) << 16; } } 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 int readInt() { checkReadableBytes0(4); ByteBuf first = buffers.peek(); int firstLen = first.readableBytes(); if (firstLen >= 4) { int res = first.readInt(); readableBytes -= 4; if (firstLen == 4) { buffers.removeFirst().release(); } return res; } else if (order() == ByteOrder.BIG_ENDIAN) { return (readShort() & 0xffff) << 16 | readShort() & 0xffff; } else { return readShort() & 0xFFFF | (readShort() & 0xFFFF) << 16; } } 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();  }