@Override public ByteBuf getBytes(int index, ByteBuf dst, int dstIndex, int length) { checkDstIndex(index, length, dstIndex, dst.capacity()); if (dst.hasMemoryAddress()) { PlatformDependent.copyMemory(memory, idx(index), dst.memoryAddress() + dstIndex, length); } else if (dst.hasArray()) { getBytes(index, dst.array(), dst.arrayOffset() + dstIndex, length); } else { dst.setBytes(dstIndex, memory, idx(index), length); } return this; }
@Override public ByteBuf setBytes(int index, ByteBuf src, int srcIndex, int length) { checkSrcIndex(index, length, srcIndex, src.capacity()); if (src.hasMemoryAddress()) { PlatformDependent.copyMemory(src.memoryAddress() + srcIndex, memory, idx(index), length); } else if (src.hasArray()) { setBytes(index, src.array(), src.arrayOffset() + srcIndex, length); } else { src.getBytes(srcIndex, memory, idx(index), length); } return this; }
@Override public ByteBuf setBytes(int index, ByteBuf src, int srcIndex, int length) { checkIndex(index, length); if (src == null) { throw new NullPointerException("src"); } if (srcIndex < 0 || srcIndex > src.capacity() - length) { throw new IndexOutOfBoundsException("srcIndex: " + srcIndex); } if (length != 0) { if (src.hasMemoryAddress()) { PlatformDependent.copyMemory(src.memoryAddress() + srcIndex, addr(index), length); } else if (src.hasArray()) { PlatformDependent.copyMemory( src.array(), src.arrayOffset() + srcIndex, addr(index), length); } else { src.getBytes(srcIndex, this, index, length); } } return this; }
@Override public ByteBuf getBytes(int index, ByteBuf dst, int dstIndex, int length) { checkIndex(index, length); if (dst == null) { throw new NullPointerException("dst"); } if (dstIndex < 0 || dstIndex > dst.capacity() - length) { throw new IndexOutOfBoundsException("dstIndex: " + dstIndex); } if (length != 0) { if (dst.hasMemoryAddress()) { PlatformDependent.copyMemory(addr(index), dst.memoryAddress() + dstIndex, length); } else if (dst.hasArray()) { PlatformDependent.copyMemory( addr(index), dst.array(), dst.arrayOffset() + dstIndex, length); } else { dst.setBytes(dstIndex, this, index, length); } } return this; }
@Override public boolean hasMemoryAddress() { return buf.hasMemoryAddress(); }