@Override public short getShort(int index) { checkIndex(index, 2); return _getShort(index); }
@Override public ByteBuf setInt(int index, int value) { checkIndex(index, 4); _setInt(index, value); return this; }
@Override public final long getLong(int index) { wrapped.checkIndex(index, 8); long v = _getLong(wrapped, index); return nativeByteOrder ? v : Long.reverseBytes(v); }
@Override public ByteBuf setMedium(int index, int value) { checkIndex(index, 3); _setMedium(index, value); return this; }
@Override public final ByteBuf setLong(int index, long value) { wrapped.checkIndex(index, 8); _setLong(wrapped, index, nativeByteOrder ? value : Long.reverseBytes(value)); return this; }
static void setBytes(AbstractByteBuf buf, long addr, int index, byte[] src, int srcIndex, int length) { buf.checkIndex(index, length); if (length != 0) { PlatformDependent.copyMemory(src, srcIndex, addr, length); } }
protected final void checkSrcIndex(int index, int length, int srcIndex, int srcCapacity) { checkIndex(index, length); if (isOutOfBounds(srcIndex, length, srcCapacity)) { throw new IndexOutOfBoundsException(String.format( "srcIndex: %d, length: %d (expected: range(0, %d))", srcIndex, length, srcCapacity)); } }
protected final void checkDstIndex(int index, int length, int dstIndex, int dstCapacity) { checkIndex(index, length); if (isOutOfBounds(dstIndex, length, dstCapacity)) { throw new IndexOutOfBoundsException(String.format( "dstIndex: %d, length: %d (expected: range(0, %d))", dstIndex, length, dstCapacity)); } }
@Override public int getUnsignedMedium(int index) { checkIndex(index, 3); return _getUnsignedMedium(index); }
@Override public ByteBuf setByte(int index, int value) { checkIndex(index); _setByte(index, value); return this; }
@Override public ByteBuf setShort(int index, int value) { checkIndex(index, 2); _setShort(index, value); return this; }
@Override public long getLong(int index) { checkIndex(index, 8); return _getLong(index); }
@Override public ByteBuf setShort(int index, int value) { checkIndex(index, 2); _setShort(index, value); return this; }
@Override public byte getByte(int index) { checkIndex(index); return _getByte(index); }
@Override public short getShort(int index) { checkIndex(index, 2); return _getShort(index); }
@Override public ByteBuf setInt(int index, int value) { checkIndex(index, 4); _setInt(index, value); return this; }
@Override public int forEachByte(int index, int length, ByteBufProcessor processor) { checkIndex(index, length); try { return forEachByteAsc0(index, index + length, processor); } catch (Exception e) { PlatformDependent.throwException(e); return -1; } }
@Override public int forEachByteDesc(int index, int length, ByteBufProcessor processor) { checkIndex(index, length); try { return forEachByteDesc0(index + length - 1, index, processor); } catch (Exception e) { PlatformDependent.throwException(e); return -1; } }
@Override public int forEachByteDesc(int index, int length, ByteBufProcessor processor) { checkIndex(index, length); try { return forEachByteDesc0(index + length - 1, index, processor); } catch (Exception e) { PlatformDependent.throwException(e); return -1; } }
static ByteBuf copy(AbstractByteBuf buf, long addr, int index, int length) { buf.checkIndex(index, length); ByteBuf copy = buf.alloc().directBuffer(length, buf.maxCapacity()); if (length != 0) { if (copy.hasMemoryAddress()) { PlatformDependent.copyMemory(addr, copy.memoryAddress(), length); copy.setIndex(0, length); } else { copy.writeBytes(buf, index, length); } } return copy; }