@Test public void testReadShort() { byte[] bytes = new byte[] {1, 2, 34, 45, 56}; ByteBuf buf = Unpooled.wrappedBuffer(bytes); DynamicCompositeByteBuf compositeByteBuf = new DynamicCompositeByteBuf(buf); short s = compositeByteBuf.readShort(); Assert.assertTrue(s == 258); }
public short readShort() { checkReadableBytes0(2); short res; ByteBuf first = buffers.peek(); int firstLen = first.readableBytes(); if (firstLen >= 2) { res = first.readShort(); readableBytes -= 2; if (firstLen == 2) { buffers.removeFirst().release(); } } else if (order() == ByteOrder.BIG_ENDIAN) { res = (short) ((readByte() & 0xff) << 8 | readByte() & 0xff); } else { res = (short) (readByte() & 0xff | (readByte() & 0xff) << 8); } return res; }
DynamicCompositeByteBuf { public short readShort() { checkReadableBytes0(2); short res; ByteBuf first = buffers.peek(); int firstLen = first.readableBytes(); if (firstLen >= 2) { res = first.readShort(); readableBytes -= 2; if (firstLen == 2) { buffers.removeFirst().release(); } } else if (order() == ByteOrder.BIG_ENDIAN) { res = (short) ((readByte() & 0xff) << 8 | readByte() & 0xff); } else { res = (short) (readByte() & 0xff | (readByte() & 0xff) << 8); } return res; } }
DynamicCompositeByteBuf { public short readShort() { checkReadableBytes0(2); short res; ByteBuf first = buffers.peek(); int firstLen = first.readableBytes(); if (firstLen >= 2) { res = first.readShort(); readableBytes -= 2; if (firstLen == 2) { buffers.removeFirst().release(); } } else if (order() == ByteOrder.BIG_ENDIAN) { res = (short) ((readByte() & 0xff) << 8 | readByte() & 0xff); } else { res = (short) (readByte() & 0xff | (readByte() & 0xff) << 8); } return res; } DynamicCompositeByteBuf();  DynamicCompositeByteBuf(int capacity);  DynamicCompositeByteBuf(ByteBuf buf);  DynamicCompositeByteBuf(ByteBuf[] bufs, int offset, int len); }
DynamicCompositeByteBuf { public short readShort() { checkReadableBytes0(2); short res; ByteBuf first = buffers.peek(); int firstLen = first.readableBytes(); if (firstLen >= 2) { res = first.readShort(); readableBytes -= 2; if (firstLen == 2) { buffers.removeFirst().release(); } } else if (order() == ByteOrder.BIG_ENDIAN) { res = (short) ((readByte() & 0xff) << 8 | readByte() & 0xff); } else { res = (short) (readByte() & 0xff | (readByte() & 0xff) << 8); } return res; } 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 short readShort() { checkReadableBytes0(2); short res; ByteBuf first = buffers.peek(); int firstLen = first.readableBytes(); if (firstLen >= 2) { res = first.readShort(); readableBytes -= 2; if (firstLen == 2) { buffers.removeFirst().release(); } } else if (order() == ByteOrder.BIG_ENDIAN) { res = (short) ((readByte() & 0xff) << 8 | readByte() & 0xff); } else { res = (short) (readByte() & 0xff | (readByte() & 0xff) << 8); } return res; } 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();  }