@Override public final ByteBuf getBytes(int index, OutputStream out, int length) throws IOException { checkIndex(index, length); out.write(memory, idx(index), length); return this; }
@Override public final ByteBuf setBytes(int index, ByteBuffer src) { int length = src.remaining(); checkIndex(index, length); src.get(memory, idx(index), length); return this; }
@Override public final ByteBuf getBytes(int index, ByteBuffer dst) { checkIndex(index, dst.remaining()); dst.put(memory, idx(index), dst.remaining()); return this; }
@Override public final int setBytes(int index, InputStream in, int length) throws IOException { checkIndex(index, length); return in.read(memory, idx(index), length); }
@Override public final ByteBuffer nioBuffer(int index, int length) { checkIndex(index, length); index = idx(index); ByteBuffer buf = ByteBuffer.wrap(memory, index, length); return buf.slice(); }
private int getBytes(int index, FileChannel out, long position, int length, boolean internal) throws IOException { checkIndex(index, length); index = idx(index); ByteBuffer tmpBuf = internal ? internalNioBuffer() : ByteBuffer.wrap(memory); return out.write((ByteBuffer) tmpBuf.clear().position(index).limit(index + length), position); }
@Override public final int setBytes(int index, FileChannel in, long position, int length) throws IOException { checkIndex(index, length); index = idx(index); try { return in.read((ByteBuffer) internalNioBuffer().clear().position(index).limit(index + length), position); } catch (ClosedChannelException ignored) { return -1; } }
@Override public final ByteBuf getBytes(int index, ByteBuffer dst) { checkIndex(index, dst.remaining()); dst.put(memory, idx(index), dst.remaining()); return this; }
@Override public final ByteBuf getBytes(int index, OutputStream out, int length) throws IOException { checkIndex(index, length); out.write(memory, idx(index), length); return this; }
@Override public final ByteBuf setBytes(int index, ByteBuffer src) { int length = src.remaining(); checkIndex(index, length); src.get(memory, idx(index), length); return this; }
@Override public final ByteBuffer internalNioBuffer(int index, int length) { checkIndex(index, length); index = idx(index); return (ByteBuffer) internalNioBuffer().clear().position(index).limit(index + length); }
@Override public final int setBytes(int index, InputStream in, int length) throws IOException { checkIndex(index, length); return in.read(memory, idx(index), length); }
private int getBytes(int index, FileChannel out, long position, int length, boolean internal) throws IOException { checkIndex(index, length); index = idx(index); ByteBuffer tmpBuf = internal ? internalNioBuffer() : ByteBuffer.wrap(memory); return out.write((ByteBuffer) tmpBuf.clear().position(index).limit(index + length), position); }
private int getBytes(int index, GatheringByteChannel out, int length, boolean internal) throws IOException { checkIndex(index, length); index = idx(index); ByteBuffer tmpBuf; if (internal) { tmpBuf = internalNioBuffer(); } else { tmpBuf = ByteBuffer.wrap(memory); } return out.write((ByteBuffer) tmpBuf.clear().position(index).limit(index + length)); }
@Override public final int setBytes(int index, FileChannel in, long position, int length) throws IOException { checkIndex(index, length); index = idx(index); try { return in.read((ByteBuffer) internalNioBuffer().clear().position(index).limit(index + length), position); } catch (ClosedChannelException ignored) { return -1; } }
@Override public final int setBytes(int index, ScatteringByteChannel in, int length) throws IOException { checkIndex(index, length); index = idx(index); try { return in.read((ByteBuffer) internalNioBuffer().clear().position(index).limit(index + length)); } catch (ClosedChannelException ignored) { return -1; } }
@Override public final ByteBuffer internalNioBuffer(int index, int length) { checkIndex(index, length); index = idx(index); return (ByteBuffer) internalNioBuffer().clear().position(index).limit(index + length); }
@Override public final int setBytes(int index, ScatteringByteChannel in, int length) throws IOException { checkIndex(index, length); index = idx(index); try { return in.read((ByteBuffer) internalNioBuffer().clear().position(index).limit(index + length)); } catch (ClosedChannelException ignored) { return -1; } }
@Override public final ByteBuf copy(int index, int length) { checkIndex(index, length); ByteBuf copy = alloc().heapBuffer(length, maxCapacity()); copy.writeBytes(memory, idx(index), length); return copy; }
@Override public final ByteBuf copy(int index, int length) { checkIndex(index, length); ByteBuf copy = alloc().heapBuffer(length, maxCapacity()); copy.writeBytes(memory, idx(index), length); return copy; }