/** * Appends {@code len} chars to this buffer from the given source * char array buffer starting at index {@code off}. The capacity * of the buffer is increased if necessary to accommodate all * {@code len} chars. * <p> * The chars are converted to bytes using simple cast. * * @param b the chars to be appended. * @param off the index of the first char to append. * @param len the number of bytes to append. * @throws IndexOutOfBoundsException if {@code off} if out of * range, {@code len} is negative, or * {@code off} + {@code len} is out of range. */ public void append(final CharArrayBuffer b, final int off, final int len) { if (b == null) { return; } append(b.array(), off, len); }
/** * Appends {@code len} chars to this buffer from the given source * char array buffer starting at index {@code off}. The capacity * of the buffer is increased if necessary to accommodate all * {@code len} chars. * <p> * The chars are converted to bytes using simple cast. * * @param b the chars to be appended. * @param off the index of the first char to append. * @param len the number of bytes to append. * @throws IndexOutOfBoundsException if {@code off} if out of * range, {@code len} is negative, or * {@code off} + {@code len} is out of range. */ public void append(final CharArrayBuffer b, final int off, final int len) { if (b == null) { return; } append(b.array(), off, len); }
@Override protected final void data(final CharBuffer src, final boolean endOfStream) { Args.notNull(src, "CharBuffer"); final int chunk = src.remaining(); content.ensureCapacity(chunk); src.get(content.array(), content.length(), chunk); content.setLength(content.length() + chunk); }
@Override protected final void data(final CharBuffer src, final boolean endOfStream) { Args.notNull(src, "CharBuffer"); final int chunk = src.remaining(); content.ensureCapacity(chunk); src.get(content.array(), content.length(), chunk); content.setLength(content.length() + chunk); }
this.charbuffer.put(lineBuffer.array(), offset, l); this.charbuffer.flip();
this.charbuffer.put(lineBuffer.array(), offset, l); this.charbuffer.flip();
final CharBuffer cbuf = CharBuffer.wrap(charbuffer.array(), 0, charbuffer.length()); writeEncoded(cbuf, outputStream);
final CharBuffer cbuf = CharBuffer.wrap(charbuffer.array(), 0, charbuffer.length()); writeEncoded(cbuf, outputStream);
@Test public void testConstructor() throws Exception { final CharArrayBuffer buffer = new CharArrayBuffer(16); Assert.assertEquals(16, buffer.capacity()); Assert.assertEquals(0, buffer.length()); Assert.assertNotNull(buffer.array()); Assert.assertEquals(16, buffer.array().length); try { new CharArrayBuffer(-1); Assert.fail("IllegalArgumentException should have been thrown"); } catch (final IllegalArgumentException ex) { // expected } }