private void getBytes(int index, byte[] dst, int dstIndex, int length, boolean internal) { checkDstIndex(index, length, dstIndex, dst.length); ByteBuffer tmpBuf; if (internal) { tmpBuf = internalNioBuffer(); } else { tmpBuf = memory.duplicate(); } index = idx(index); tmpBuf.clear().position(index).limit(index + length); tmpBuf.get(dst, dstIndex, length); }
@Override public ByteBuf setBytes(int index, ByteBuffer src) { checkIndex(index, src.remaining()); ByteBuffer tmpBuf = internalNioBuffer(); if (src == tmpBuf) { src = src.duplicate(); } index = idx(index); tmpBuf.clear().position(index).limit(index + src.remaining()); tmpBuf.put(src); return this; }
private void getBytes(int index, ByteBuffer dst, boolean internal) { checkIndex(index, dst.remaining()); ByteBuffer tmpBuf; if (internal) { tmpBuf = internalNioBuffer(); } else { tmpBuf = memory.duplicate(); } index = idx(index); tmpBuf.clear().position(index).limit(index + dst.remaining()); dst.put(tmpBuf); }
@Override public ByteBuf setBytes(int index, ByteBuffer src) { checkIndex(index, src.remaining()); ByteBuffer tmpBuf = internalNioBuffer(); if (src == tmpBuf) { src = src.duplicate(); } index = idx(index); tmpBuf.clear().position(index).limit(index + src.remaining()); tmpBuf.put(src); return this; }
private void getBytes(int index, ByteBuffer dst, boolean internal) { checkIndex(index, dst.remaining()); ByteBuffer tmpBuf; if (internal) { tmpBuf = internalNioBuffer(); } else { tmpBuf = memory.duplicate(); } index = idx(index); tmpBuf.clear().position(index).limit(index + dst.remaining()); dst.put(tmpBuf); }
private void getBytes(int index, byte[] dst, int dstIndex, int length, boolean internal) { checkDstIndex(index, length, dstIndex, dst.length); ByteBuffer tmpBuf; if (internal) { tmpBuf = internalNioBuffer(); } else { tmpBuf = memory.duplicate(); } index = idx(index); tmpBuf.clear().position(index).limit(index + length); tmpBuf.get(dst, dstIndex, length); }
@Override public ByteBuf setBytes(int index, byte[] src, int srcIndex, int length) { checkSrcIndex(index, length, srcIndex, src.length); ByteBuffer tmpBuf = internalNioBuffer(); index = idx(index); tmpBuf.clear().position(index).limit(index + length); tmpBuf.put(src, srcIndex, length); return this; }
@Override public ByteBuffer internalNioBuffer(int index, int length) { checkIndex(index, length); index = idx(index); return (ByteBuffer) internalNioBuffer().clear().position(index).limit(index + length); }
@Override public int setBytes(int index, InputStream in, int length) throws IOException { checkIndex(index, length); byte[] tmp = new byte[length]; int readBytes = in.read(tmp); if (readBytes <= 0) { return readBytes; } ByteBuffer tmpBuf = internalNioBuffer(); tmpBuf.clear().position(idx(index)); tmpBuf.put(tmp, 0, readBytes); return readBytes; }
@Override public ByteBuf setBytes(int index, byte[] src, int srcIndex, int length) { checkSrcIndex(index, length, srcIndex, src.length); ByteBuffer tmpBuf = internalNioBuffer(); index = idx(index); tmpBuf.clear().position(index).limit(index + length); tmpBuf.put(src, srcIndex, length); return this; }
@Override public ByteBuffer internalNioBuffer(int index, int length) { checkIndex(index, length); index = idx(index); return (ByteBuffer) internalNioBuffer().clear().position(index).limit(index + length); }
@Override public int setBytes(int index, InputStream in, int length) throws IOException { checkIndex(index, length); byte[] tmp = new byte[length]; int readBytes = in.read(tmp); if (readBytes <= 0) { return readBytes; } ByteBuffer tmpBuf = internalNioBuffer(); tmpBuf.clear().position(idx(index)); tmpBuf.put(tmp, 0, readBytes); return readBytes; }
private void getBytes(int index, OutputStream out, int length, boolean internal) throws IOException { checkIndex(index, length); if (length == 0) { return; } byte[] tmp = new byte[length]; ByteBuffer tmpBuf; if (internal) { tmpBuf = internalNioBuffer(); } else { tmpBuf = memory.duplicate(); } tmpBuf.clear().position(idx(index)); tmpBuf.get(tmp); out.write(tmp); }
private void getBytes(int index, OutputStream out, int length, boolean internal) throws IOException { checkIndex(index, length); if (length == 0) { return; } byte[] tmp = new byte[length]; ByteBuffer tmpBuf; if (internal) { tmpBuf = internalNioBuffer(); } else { tmpBuf = memory.duplicate(); } tmpBuf.clear().position(idx(index)); tmpBuf.get(tmp); out.write(tmp); }
@Override public int setBytes(int index, ScatteringByteChannel in, int length) throws IOException { checkIndex(index, length); ByteBuffer tmpBuf = internalNioBuffer(); index = idx(index); tmpBuf.clear().position(index).limit(index + length); try { return in.read(tmpBuf); } catch (ClosedChannelException ignored) { return -1; } }
@Override public int setBytes(int index, ScatteringByteChannel in, int length) throws IOException { checkIndex(index, length); ByteBuffer tmpBuf = internalNioBuffer(); index = idx(index); tmpBuf.clear().position(index).limit(index + length); try { return in.read(tmpBuf); } catch (ClosedChannelException ignored) { return -1; } }
private int getBytes(int index, GatheringByteChannel out, int length, boolean internal) throws IOException { checkIndex(index, length); if (length == 0) { return 0; } ByteBuffer tmpBuf; if (internal) { tmpBuf = internalNioBuffer(); } else { tmpBuf = memory.duplicate(); } index = idx(index); tmpBuf.clear().position(index).limit(index + length); return out.write(tmpBuf); }
private int getBytes(int index, GatheringByteChannel out, int length, boolean internal) throws IOException { checkIndex(index, length); if (length == 0) { return 0; } ByteBuffer tmpBuf; if (internal) { tmpBuf = internalNioBuffer(); } else { tmpBuf = memory.duplicate(); } index = idx(index); tmpBuf.clear().position(index).limit(index + length); return out.write(tmpBuf); }