/** * Creates a new byte buffer by wrapping the given byte array. * <p> * Calling this method has the same effect as * {@code wrap(array, 0, array.length)}. * * @param array * the byte array which the new buffer will be based on * @return the created byte buffer. */ public static ByteBuffer wrap(byte[] array) { return new ByteArrayBuffer(array); }
/** * Creates a byte buffer based on a newly allocated byte array. * * @param capacity * the capacity of the new buffer * @return the created byte buffer. * @throws IllegalArgumentException * if {@code capacity < 0}. */ public static ByteBuffer allocate(int capacity) { if (capacity < 0) { throw new IllegalArgumentException("capacity < 0: " + capacity); } return new ByteArrayBuffer(new byte[capacity]); }
@Override public ByteBuffer slice() { return new ByteArrayBuffer(remaining(), backingArray, arrayOffset + position, isReadOnly); }
/** * Creates a new byte buffer by wrapping the given byte array. * <p> * The new buffer's position will be {@code start}, limit will be * {@code start + byteCount}, capacity will be the length of the array. * * @param array * the byte array which the new buffer will be based on. * @param start * the start index, must not be negative and not greater than * {@code array.length}. * @param byteCount * the length, must not be negative and not greater than * {@code array.length - start}. * @return the created byte buffer. * @exception IndexOutOfBoundsException * if either {@code start} or {@code byteCount} is invalid. */ public static ByteBuffer wrap(byte[] array, int start, int byteCount) { Arrays.checkOffsetAndCount(array.length, start, byteCount); ByteBuffer buf = new ByteArrayBuffer(array); buf.position = start; buf.limit = start + byteCount; return buf; }
private static ByteArrayBuffer copy(ByteArrayBuffer other, int markOfOther, boolean isReadOnly) { ByteArrayBuffer buf = new ByteArrayBuffer(other.capacity(), other.backingArray, other.arrayOffset, isReadOnly); buf.limit = other.limit; buf.position = other.position(); buf.mark = markOfOther; return buf; }
/** * Creates a new byte buffer by wrapping the given byte array. * <p> * Calling this method has the same effect as * {@code wrap(array, 0, array.length)}. * * @param array * the byte array which the new buffer will be based on * @return the created byte buffer. */ public static ByteBuffer wrap(byte[] array) { return new ByteArrayBuffer(array); }
/** * Creates a new byte buffer by wrapping the given byte array. * <p> * Calling this method has the same effect as * {@code wrap(array, 0, array.length)}. * * @param array * the byte array which the new buffer will be based on * @return the created byte buffer. */ public static ByteBuffer wrap(byte[] array) { return new ByteArrayBuffer(array); }
/** * Creates a new byte buffer by wrapping the given byte array. * <p> * Calling this method has the same effect as * {@code wrap(array, 0, array.length)}. * * @param array * the byte array which the new buffer will be based on * @return the created byte buffer. */ public static ByteBuffer wrap(byte[] array) { return new ByteArrayBuffer(array); }
/** * Creates a new byte buffer by wrapping the given byte array. * <p> * Calling this method has the same effect as * {@code wrap(array, 0, array.length)}. * * @param array * the byte array which the new buffer will be based on * @return the created byte buffer. */ public static ByteBuffer wrap(byte[] array) { return new ByteArrayBuffer(array); }
/** * Creates a byte buffer based on a newly allocated byte array. * * @param capacity * the capacity of the new buffer * @return the created byte buffer. * @throws IllegalArgumentException * if {@code capacity < 0}. */ public static ByteBuffer allocate(int capacity) { if (capacity < 0) { throw new IllegalArgumentException("capacity < 0: " + capacity); } return new ByteArrayBuffer(new byte[capacity]); }
/** * Creates a byte buffer based on a newly allocated byte array. * * @param capacity * the capacity of the new buffer * @return the created byte buffer. * @throws IllegalArgumentException * if {@code capacity < 0}. */ public static ByteBuffer allocate(int capacity) { if (capacity < 0) { throw new IllegalArgumentException("capacity < 0: " + capacity); } return new ByteArrayBuffer(new byte[capacity]); }
@Override public ByteBuffer slice() { return new ByteArrayBuffer(remaining(), backingArray, arrayOffset + position, isReadOnly); }
@Override public ByteBuffer slice() { return new ByteArrayBuffer(remaining(), backingArray, arrayOffset + position, isReadOnly); }
@Override public ByteBuffer slice() { return new ByteArrayBuffer(remaining(), backingArray, arrayOffset + position, isReadOnly); }
private static ByteArrayBuffer copy(ByteArrayBuffer other, int markOfOther, boolean isReadOnly) { ByteArrayBuffer buf = new ByteArrayBuffer(other.capacity(), other.backingArray, other.arrayOffset, isReadOnly); buf.limit = other.limit; buf.position = other.position(); buf.mark = markOfOther; return buf; }
private static ByteArrayBuffer copy(ByteArrayBuffer other, int markOfOther, boolean isReadOnly) { ByteArrayBuffer buf = new ByteArrayBuffer(other.capacity(), other.backingArray, other.arrayOffset, isReadOnly); buf.limit = other.limit; buf.position = other.position(); buf.mark = markOfOther; return buf; }
private static ByteArrayBuffer copy(ByteArrayBuffer other, int markOfOther, boolean isReadOnly) { ByteArrayBuffer buf = new ByteArrayBuffer(other.capacity(), other.backingArray, other.arrayOffset, isReadOnly); buf.limit = other.limit; buf.position = other.position(); buf.mark = markOfOther; return buf; }
private static ByteArrayBuffer copy(ByteArrayBuffer other, int markOfOther, boolean isReadOnly) { ByteArrayBuffer buf = new ByteArrayBuffer(other.capacity(), other.backingArray, other.arrayOffset, isReadOnly); buf.limit = other.limit; buf.position = other.position(); buf.mark = markOfOther; return buf; }
private static ByteArrayBuffer copy(ByteArrayBuffer other, int markOfOther, boolean isReadOnly) { ByteArrayBuffer buf = new ByteArrayBuffer(other.capacity(), other.backingArray, other.arrayOffset, isReadOnly); buf.limit = other.limit; buf.position = other.position(); buf.mark = markOfOther; return buf; }
private static ByteArrayBuffer copy(ByteArrayBuffer other, int markOfOther, boolean isReadOnly) { ByteArrayBuffer buf = new ByteArrayBuffer(other.capacity(), other.backingArray, other.arrayOffset, isReadOnly); buf.limit = other.limit; buf.position = other.position(); buf.mark = markOfOther; return buf; }