@Test public void testGetLongByteWithNothingAppended() { CompositeReadableBuffer buffer = new CompositeReadableBuffer(); try { buffer.getLong(); fail("Should throw a BufferUnderflowException"); } catch (BufferUnderflowException e) {} }
@Override public long getLong() { if (remaining() < LONG_BYTES) { throw new BufferUnderflowException(); } long result = 0; if (currentArray.length - currentOffset >= 8) { result = (long)(currentArray[currentOffset++] & 0xFF) << 56 | (long)(currentArray[currentOffset++] & 0xFF) << 48 | (long)(currentArray[currentOffset++] & 0xFF) << 40 | (long)(currentArray[currentOffset++] & 0xFF) << 32 | (long)(currentArray[currentOffset++] & 0xFF) << 24 | (long)(currentArray[currentOffset++] & 0xFF) << 16 | (long)(currentArray[currentOffset++] & 0xFF) << 8 | (long)(currentArray[currentOffset++] & 0xFF) << 0; maybeMoveToNextArray(); } else { for (int i = LONG_BYTES - 1; i >= 0; --i) { result |= (long)(currentArray[currentOffset++] & 0xFF) << (i * Byte.SIZE); maybeMoveToNextArray(); } } position += 8; return result; }
CompositeReadableBuffer implements ReadableBuffer { @Override public long getLong() { if (remaining() < LONG_BYTES) { throw new BufferUnderflowException(); } long result = 0; if (currentArray.length - currentOffset >= 8) { result = (long)(currentArray[currentOffset++] & 0xFF) << 56 | (long)(currentArray[currentOffset++] & 0xFF) << 48 | (long)(currentArray[currentOffset++] & 0xFF) << 40 | (long)(currentArray[currentOffset++] & 0xFF) << 32 | (long)(currentArray[currentOffset++] & 0xFF) << 24 | (long)(currentArray[currentOffset++] & 0xFF) << 16 | (long)(currentArray[currentOffset++] & 0xFF) << 8 | (long)(currentArray[currentOffset++] & 0xFF) << 0; maybeMoveToNextArray(); } else { for (int i = LONG_BYTES - 1; i >= 0; --i) { result |= (long)(currentArray[currentOffset++] & 0xFF) << (i * Byte.SIZE); maybeMoveToNextArray(); } } position += 8; return result; } }
CompositeReadableBuffer implements ReadableBuffer { @Override public long getLong() { if (remaining() < LONG_BYTES) { throw new BufferUnderflowException(); } long result = 0; if (currentArray.length - currentOffset >= 8) { result = (long)(currentArray[currentOffset++] & 0xFF) << 56 | (long)(currentArray[currentOffset++] & 0xFF) << 48 | (long)(currentArray[currentOffset++] & 0xFF) << 40 | (long)(currentArray[currentOffset++] & 0xFF) << 32 | (long)(currentArray[currentOffset++] & 0xFF) << 24 | (long)(currentArray[currentOffset++] & 0xFF) << 16 | (long)(currentArray[currentOffset++] & 0xFF) << 8 | (long)(currentArray[currentOffset++] & 0xFF) << 0; maybeMoveToNextArray(); } else { for (int i = LONG_BYTES - 1; i >= 0; --i) { result |= (long)(currentArray[currentOffset++] & 0xFF) << (i * Byte.SIZE); maybeMoveToNextArray(); } } position += 8; return result; } CompositeReadableBuffer(); private  CompositeReadableBuffer(byte[] array, int offset); private  CompositeReadableBuffer(boolean compactable); }
CompositeReadableBuffer implements ReadableBuffer { @Override public long getLong() { if (remaining() < LONG_BYTES) { throw new BufferUnderflowException(); } long result = 0; if (currentArray.length - currentOffset >= 8) { result = (long)(currentArray[currentOffset++] & 0xFF) << 56 | (long)(currentArray[currentOffset++] & 0xFF) << 48 | (long)(currentArray[currentOffset++] & 0xFF) << 40 | (long)(currentArray[currentOffset++] & 0xFF) << 32 | (long)(currentArray[currentOffset++] & 0xFF) << 24 | (long)(currentArray[currentOffset++] & 0xFF) << 16 | (long)(currentArray[currentOffset++] & 0xFF) << 8 | (long)(currentArray[currentOffset++] & 0xFF) << 0; maybeMoveToNextArray(); } else { for (int i = LONG_BYTES - 1; i >= 0; --i) { result |= (long)(currentArray[currentOffset++] & 0xFF) << (i * Byte.SIZE); maybeMoveToNextArray(); } } position += 8; return result; } CompositeReadableBuffer(); private  CompositeReadableBuffer(byte[] array, int offset); private  CompositeReadableBuffer(boolean compactable); List<byte[]> getArrays(); int getCurrentIndex(); int getCurrentArrayPosition(); @Override boolean hasArray(); @Override int capacity(); @Override byte[] array(); @Override int arrayOffset(); @Override byte get(); @Override byte get(int index); @Override int getInt(); @Override long getLong(); @Override short getShort(); @Override float getFloat(); @Override double getDouble(); @Override CompositeReadableBuffer get(byte[] data); @Override CompositeReadableBuffer get(byte[] data, int offset, int length); @Override CompositeReadableBuffer get(WritableBuffer target); @Override CompositeReadableBuffer position(int position); @Override int position(); @Override CompositeReadableBuffer slice(); @Override CompositeReadableBuffer flip(); @Override CompositeReadableBuffer limit(int limit); @Override int limit(); @Override CompositeReadableBuffer mark(); @Override CompositeReadableBuffer reset(); @Override CompositeReadableBuffer rewind(); @Override CompositeReadableBuffer clear(); @Override int remaining(); @Override boolean hasRemaining(); @Override CompositeReadableBuffer duplicate(); @Override ByteBuffer byteBuffer(); @Override String readUTF8(); @Override String readString(CharsetDecoder decoder); @Override CompositeReadableBuffer reclaimRead(); CompositeReadableBuffer append(byte[] array); CompositeReadableBuffer append(CompositeReadableBuffer buffer); CompositeReadableBuffer append(ReadableBuffer buffer); @Override int hashCode(); @Override boolean equals(Object other); @Override String toString(); }
CompositeReadableBuffer implements ReadableBuffer { @Override public long getLong() { if (remaining() < LONG_BYTES) { throw new BufferUnderflowException(); } long result = 0; if (currentArray.length - currentOffset >= 8) { result = (long)(currentArray[currentOffset++] & 0xFF) << 56 | (long)(currentArray[currentOffset++] & 0xFF) << 48 | (long)(currentArray[currentOffset++] & 0xFF) << 40 | (long)(currentArray[currentOffset++] & 0xFF) << 32 | (long)(currentArray[currentOffset++] & 0xFF) << 24 | (long)(currentArray[currentOffset++] & 0xFF) << 16 | (long)(currentArray[currentOffset++] & 0xFF) << 8 | (long)(currentArray[currentOffset++] & 0xFF) << 0; maybeMoveToNextArray(); } else { for (int i = LONG_BYTES - 1; i >= 0; --i) { result |= (long)(currentArray[currentOffset++] & 0xFF) << (i * Byte.SIZE); maybeMoveToNextArray(); } } position += 8; return result; } CompositeReadableBuffer(); private  CompositeReadableBuffer(byte[] array, int offset); private  CompositeReadableBuffer(boolean compactable); List<byte[]> getArrays(); int getCurrentIndex(); int getCurrentArrayPosition(); @Override boolean hasArray(); @Override int capacity(); @Override byte[] array(); @Override int arrayOffset(); @Override byte get(); @Override byte get(int index); @Override int getInt(); @Override long getLong(); @Override short getShort(); @Override float getFloat(); @Override double getDouble(); @Override CompositeReadableBuffer get(byte[] data); @Override CompositeReadableBuffer get(byte[] data, int offset, int length); @Override CompositeReadableBuffer get(WritableBuffer target); @Override CompositeReadableBuffer position(int position); @Override int position(); @Override CompositeReadableBuffer slice(); @Override CompositeReadableBuffer flip(); @Override CompositeReadableBuffer limit(int limit); @Override int limit(); @Override CompositeReadableBuffer mark(); @Override CompositeReadableBuffer reset(); @Override CompositeReadableBuffer rewind(); @Override CompositeReadableBuffer clear(); @Override int remaining(); @Override boolean hasRemaining(); @Override CompositeReadableBuffer duplicate(); @Override ByteBuffer byteBuffer(); @Override String readUTF8(); @Override String readString(CharsetDecoder decoder); @Override CompositeReadableBuffer reclaimRead(); CompositeReadableBuffer append(byte[] array); CompositeReadableBuffer append(CompositeReadableBuffer buffer); CompositeReadableBuffer append(ReadableBuffer buffer); @Override int hashCode(); @Override boolean equals(Object other); @Override String toString();  }