@Test public void testSetInvalidLength() throws Exception { final ByteArrayBuffer buffer = new ByteArrayBuffer(4); try { buffer.setLength(-2); Assert.fail("IndexOutOfBoundsException should have been thrown"); } catch (final IndexOutOfBoundsException ex) { } try { buffer.setLength(200); Assert.fail("IndexOutOfBoundsException should have been thrown"); } catch (final IndexOutOfBoundsException ex) { } }
public void setLength(final int len) { if (len < 0 || len > this.array.length) { throw new IndexOutOfBoundsException("len: "+len+" < 0 or > buffer len: "+this.array.length); } this.len = len; }
ByteArrayBuffer implements Serializable { public void setLength(final int len) { if (len < 0 || len > this.array.length) { throw new IndexOutOfBoundsException("len: "+len+" < 0 or > buffer len: "+this.array.length); } this.len = len; } }
ByteArrayBuffer implements Serializable { public void setLength(final int len) { if (len < 0 || len > this.array.length) { throw new IndexOutOfBoundsException("len: "+len+" < 0 or > buffer len: "+this.array.length); } this.len = len; } ByteArrayBuffer(final int capacity); }
ByteArrayBuffer implements Serializable { public void setLength(final int len) { if (len < 0 || len > this.array.length) { throw new IndexOutOfBoundsException("len: "+len+" < 0 or > buffer len: "+this.array.length); } this.len = len; } ByteArrayBuffer(final int capacity); void append(final byte[] b, final int off, final int len); void append(final int b); void append(final char[] b, final int off, final int len); void append(final CharArrayBuffer b, final int off, final int len); void append(final ByteBuffer buffer); void clear(); byte[] toByteArray(); int byteAt(final int i); int capacity(); int length(); void ensureCapacity(final int required); byte[] array(); void setLength(final int len); boolean isEmpty(); boolean isFull(); int indexOf(final byte b, final int from, final int to); int indexOf(final byte b); }
ByteArrayBuffer implements Serializable { public void setLength(final int len) { if (len < 0 || len > this.array.length) { throw new IndexOutOfBoundsException("len: "+len+" < 0 or > buffer len: "+this.array.length); } this.len = len; } ByteArrayBuffer(final int capacity); void append(final byte[] b, final int off, final int len); void append(final int b); void append(final char[] b, final int off, final int len); void append(final CharArrayBuffer b, final int off, final int len); void append(final ByteBuffer buffer); void clear(); byte[] toByteArray(); int byteAt(final int i); int capacity(); int length(); void ensureCapacity(final int required); byte[] array(); void setLength(final int len); boolean isEmpty(); boolean isFull(); int indexOf(final byte b, final int from, final int to); int indexOf(final byte b);  }