public Buffer asReadOnlyBuffer() { if (isReadOnly()) return this; return new View(this, markIndex(), getIndex(), putIndex(), READONLY); }
public int poke(int index, byte[] b, int offset, int length) { _hash=0; if (isReadOnly()) throw new IllegalStateException(__READONLY); if (index < 0) throw new IllegalArgumentException("index<0: " + index + "<0"); if (index + length > capacity()) { length=capacity()-index; if (length<0) throw new IllegalArgumentException("index>capacity(): " + index + ">" + capacity()); } byte[] dst_array = array(); if (dst_array != null) Portable.arraycopy(b, offset, dst_array, index, length); else { int s=offset; for (int i=0;i<length;i++) poke(index++,b[s++]); } return length; }
public Buffer peek(int index, int length) { if (_view == null) { _view = new View(this, -1, index, index + length, isReadOnly() ? READONLY : READWRITE); } else { _view.update(this.buffer()); _view.setMarkIndex(-1); _view.setGetIndex(0); _view.setPutIndex(index + length); _view.setGetIndex(index); } return _view; }
public int poke(int index, Buffer src) if (isReadOnly()) throw new IllegalStateException(__READONLY); if (index < 0) throw new IllegalArgumentException("index<0: " + index + "<0");
public void compact() { if (isReadOnly()) throw new IllegalStateException(__READONLY); int s = markIndex() >= 0 ? markIndex() : getIndex(); if (s > 0) { byte array[] = array(); int length = putIndex() - s; if (length > 0) { if (array != null) Portable.arraycopy(array(), s, array(), 0, length); else poke(0, peek(s, length)); } if (markIndex() > 0) setMarkIndex(markIndex() - s); setGetIndex(getIndex() - s); setPutIndex(putIndex() - s); } }