/** * Copies the content of this {@code ByteArray} into an existing {@code ByteBuffer}. * * @throws java.nio.ReadOnlyBufferException if the target is read-only * @throws java.nio.BufferOverflowException if the target's {@link ByteBuffer#remaining()} space * is not large enough to hold the data */ public final void copyTo(ByteBuffer target) { byteString.copyTo(target); }
/** * Copies bytes into a ByteBuffer. * * @throws java.nio.ReadOnlyBufferException if the target is read-only * @throws java.nio.BufferOverflowException if the target's remaining() space is not large enough * to hold the data */ public void copyTo(ByteBuffer target) { byteString.copyTo(target); }
/** * Copies bytes into a buffer at the given offset. * * @param target buffer to copy into * @param offset in the target buffer * @throws IndexOutOfBoundsException if the offset is negative or too large */ public void copyTo(byte[] target, int offset) { copyTo(target, 0, offset, size()); }
/** * Copies bytes into a buffer at the given offset. * * @param target buffer to copy into * @param offset in the target buffer * @throws IndexOutOfBoundsException if the offset is negative or too large */ public void copyTo(byte[] target, int offset) { copyTo(target, 0, offset, size()); }
/** * Copies the content of this {@code ByteArray} into an array of bytes. * * @throws IndexOutOfBoundsException if the target is not large enough to hold the data */ public final void copyTo(byte[] target) { byteString.copyTo(target, 0, 0, length()); }
/** * Copies bytes into a buffer. * * @throws IndexOutOfBoundsException if an offset or size is negative or too large */ public void copyTo(byte[] target) { byteString.copyTo(target, 0, 0, getLength()); }
/** * Concatenates two strings by copying data values. This is called in a few * cases in order to reduce the growth of the number of tree nodes. * * @param left string on the left * @param right string on the right * @return string formed by copying data bytes */ private static ByteString concatenateBytes(ByteString left, ByteString right) { int leftSize = left.size(); int rightSize = right.size(); byte[] bytes = new byte[leftSize + rightSize]; left.copyTo(bytes, 0, 0, leftSize); right.copyTo(bytes, 0, leftSize, rightSize); return ByteString.wrap(bytes); // Constructor wraps bytes }
/** * Concatenates two strings by copying data values. This is called in a few * cases in order to reduce the growth of the number of tree nodes. * * @param left string on the left * @param right string on the right * @return string formed by copying data bytes */ private static LiteralByteString concatenateBytes(ByteString left, ByteString right) { int leftSize = left.size(); int rightSize = right.size(); byte[] bytes = new byte[leftSize + rightSize]; left.copyTo(bytes, 0, 0, leftSize); right.copyTo(bytes, 0, leftSize, rightSize); return new LiteralByteString(bytes); // Constructor wraps bytes }
/** * Copies bytes into a ByteBuffer. * * @throws java.nio.ReadOnlyBufferException if the target is read-only * @throws java.nio.BufferOverflowException if the target's remaining() space is not large enough * to hold the data */ public void copyTo(ByteBuffer target) { byteString.copyTo(target); }
/** * Copies the content of this {@code ByteArray} into an existing {@code ByteBuffer}. * * @throws java.nio.ReadOnlyBufferException if the target is read-only * @throws java.nio.BufferOverflowException if the target's {@link ByteBuffer#remaining()} space * is not large enough to hold the data */ public final void copyTo(ByteBuffer target) { byteString.copyTo(target); }
/** * Copies bytes into a buffer at the given offset. * * @param target buffer to copy into * @param offset in the target buffer * @throws IndexOutOfBoundsException if the offset is negative or too large */ public void copyTo(byte[] target, int offset) { copyTo(target, 0, offset, size()); }
/** * Copies bytes into a buffer at the given offset. * * @param target buffer to copy into * @param offset in the target buffer * @throws IndexOutOfBoundsException if the offset is negative or too large */ public void copyTo(byte[] target, int offset) { copyTo(target, 0, offset, size()); }
/** * Copies bytes into a buffer. * * @throws IndexOutOfBoundsException if an offset or size is negative or too large */ public void copyTo(byte[] target) { byteString.copyTo(target, 0, 0, getLength()); }
/** * Copies the content of this {@code ByteArray} into an array of bytes. * * @throws IndexOutOfBoundsException if the target is not large enough to hold the data */ public final void copyTo(byte[] target) { byteString.copyTo(target, 0, 0, length()); }