/** * Set the byte at index to be new value. * * @param index to set byte * @param b is the new value. */ public void set(int index, int b) { assert index >= 0 : "index must be positive"; assert begin + index < begin + realSize : "index is too large"; bytes[begin + index] = (byte)b; invalidate(); }
/** * @param bytes the bytes to set */ public void setUnsafeBytes(byte[] bytes) { assert bytes != null; this.bytes = bytes; invalidate(); }
/** * Change ByteBuffer to have a new begin that is +index positions past begin with a new length. * * @param index new value to add to begin * @param len the new realSize/length value */ public void view(int index, int len) { realSize = len; begin = begin + index; invalidate(); }
/** * @param begin the begin to set */ public void setBegin(int begin) { assert begin >= 0; this.begin = begin; invalidate(); }
/** * @param realSize the realSize to set */ public void realSize(int realSize) { assert realSize >= 0; this.realSize = realSize; invalidate(); }
/** * @param realSize the realSize to set */ public void realSize(int realSize) { assert realSize >= 0; this.realSize = realSize; invalidate(); }
/** * Change ByteBuffer to have a new begin that is +index positions past begin with a new length. * * @param index new value to add to begin * @param len the new realSize/length value */ public void view(int index, int len) { realSize = len; begin = begin + index; invalidate(); }
/** * Append moreBytes onto the end of the current ByteList. * * @param moreBytes to be added. */ public void append(byte[] moreBytes) { assert moreBytes != null : "moreBytes is null"; grow(moreBytes.length); System.arraycopy(moreBytes, 0, bytes, begin + realSize, moreBytes.length); realSize += moreBytes.length; invalidate(); }
/** * Append moreBytes onto the end of the current ByteList. * * @param moreBytes to be added. */ public void append(byte[] moreBytes) { assert moreBytes != null : "moreBytes is null"; grow(moreBytes.length); System.arraycopy(moreBytes, 0, bytes, begin + realSize, moreBytes.length); realSize += moreBytes.length; invalidate(); }
/** * Prepend a byte onto the front of this ByteList. * * @param b is the byte to be prepended */ public void prepend(byte b) { grow(1); System.arraycopy(bytes, begin + 0, bytes, begin + 1, realSize); bytes[begin + 0] = b; realSize++; invalidate(); }
/** * Unsafe version of replace(int,int,byte[],int,int). The contract is that these * unsafe versions will not make sure thet beg and len indices are correct. */ public void unsafeReplace(int beg, int len, byte[] nbytes, int index, int count) { grow(count - len); int newSize = realSize + count - len; System.arraycopy(bytes, beg+len, bytes, beg+count, realSize - (len + beg)); System.arraycopy(nbytes, index, bytes, beg, count); realSize = newSize; invalidate(); }
public void insert(int index, int b) { grow(1); System.arraycopy(bytes, index, bytes, index + 1, realSize - index); bytes[index] = (byte)b; realSize++; invalidate(); }
/** * @param encoding the encoding to set */ public void setEncoding(Encoding encoding) { assert encoding != null; this.encoding = safeEncoding(encoding); invalidate(); }
/** * Append contents of the supplied nio ByteList up to len length onto the end of this * ByteBuffer. * * @param buffer to be appended * @param len is number of bytes you hoping to get from the ByteBuffer */ public void append(ByteBuffer buffer, int len) { grow(len); buffer.get(bytes, begin + realSize, len); realSize += len; invalidate(); }
/** * Unsafe version of replace(int,int,byte[],int,int). The contract is that these * unsafe versions will not make sure thet beg and len indices are correct. */ public void unsafeReplace(int beg, int len, byte[] nbytes, int index, int count) { grow(count - len); int newSize = realSize + count - len; System.arraycopy(bytes, beg+len, bytes, beg+count, realSize - (len + beg)); System.arraycopy(nbytes, index, bytes, beg, count); realSize = newSize; invalidate(); }
public void insert(int index, int b) { grow(1); System.arraycopy(bytes, index, bytes, index + 1, realSize - index); bytes[index] = (byte)b; realSize++; invalidate(); }
/** * @param encoding the encoding to set */ public void setEncoding(Encoding encoding) { assert encoding != null; this.encoding = safeEncoding(encoding); invalidate(); }
private static void resetBuffer(ByteList l) { l.setBegin(0); l.setRealSize(0); l.invalidate(); } }
private void view(byte[] bytes, boolean copy) { modifyCheck(); value = new ByteList(bytes, copy); shareLevel = SHARE_LEVEL_NONE; value.invalidate(); }
private void view(byte[] bytes, boolean copy) { modifyCheck(); value = new ByteList(bytes, copy); shareLevel = SHARE_LEVEL_NONE; value.invalidate(); }