@Test public void testSetInvalidLength() throws Exception { ByteArrayBuffer buffer = new ByteArrayBuffer(4); try { buffer.setLength(-2); Assert.fail("IndexOutOfBoundsException should have been thrown"); } catch (IndexOutOfBoundsException ex) { } try { buffer.setLength(200); Assert.fail("IndexOutOfBoundsException should have been thrown"); } catch (IndexOutOfBoundsException ex) { } }
public void setLength(int len) { if (len < 0 || len > this.buffer.length) { throw new IndexOutOfBoundsException(); } this.len = len; }
ByteArrayBuffer implements ByteSequence { public void setLength(int len) { if (len < 0 || len > this.buffer.length) { throw new IndexOutOfBoundsException(); } this.len = len; } }
ByteArrayBuffer implements ByteSequence { public void setLength(int len) { if (len < 0 || len > this.buffer.length) { throw new IndexOutOfBoundsException(); } this.len = len; } ByteArrayBuffer(int capacity);  ByteArrayBuffer(byte[] bytes, boolean dontCopy);  ByteArrayBuffer(byte[] bytes, int len, boolean dontCopy); }
ByteArrayBuffer implements ByteSequence { public void setLength(int len) { if (len < 0 || len > this.buffer.length) { throw new IndexOutOfBoundsException(); } this.len = len; } ByteArrayBuffer(int capacity);  ByteArrayBuffer(byte[] bytes, boolean dontCopy);  ByteArrayBuffer(byte[] bytes, int len, boolean dontCopy); void append(final byte[] b, int off, int len); void append(int b); void clear(); byte[] toByteArray(); byte byteAt(int i); int capacity(); int length(); byte[] buffer(); int indexOf(byte b); int indexOf(byte b, int beginIndex, int endIndex); void setLength(int len); void remove(int off, int len); boolean isEmpty(); boolean isFull(); @Override String toString(); }
ByteArrayBuffer implements ByteSequence { public void setLength(int len) { if (len < 0 || len > this.buffer.length) { throw new IndexOutOfBoundsException(); } this.len = len; } ByteArrayBuffer(int capacity);  ByteArrayBuffer(byte[] bytes, boolean dontCopy);  ByteArrayBuffer(byte[] bytes, int len, boolean dontCopy); void append(final byte[] b, int off, int len); void append(int b); void clear(); byte[] toByteArray(); byte byteAt(int i); int capacity(); int length(); byte[] buffer(); int indexOf(byte b); int indexOf(byte b, int beginIndex, int endIndex); void setLength(int len); void remove(int off, int len); boolean isEmpty(); boolean isFull(); @Override String toString();  }