/** * Appends {@code ch} char to this buffer. The capacity of the buffer * is increased, if necessary, to accommodate the additional char. * * @param ch the char to be appended. */ public void append(final char ch) { final int newlen = this.len + 1; if (newlen > this.array.length) { expand(newlen); } this.array[this.len] = ch; this.len = newlen; }
/** * Appends {@code ch} char to this buffer. The capacity of the buffer * is increased, if necessary, to accommodate the additional char. * * @param ch the char to be appended. */ public void append(final char ch) { final int newlen = this.len + 1; if (newlen > this.array.length) { expand(newlen); } this.array[this.len] = ch; this.len = newlen; }
/** * Ensures that the capacity is at least equal to the specified minimum. * If the current capacity is less than the argument, then a new internal * array is allocated with greater capacity. If the {@code required} * argument is non-positive, this method takes no action. * * @param required the minimum required capacity. */ public void ensureCapacity(final int required) { if (required <= 0) { return; } final int available = this.array.length - this.len; if (required > available) { expand(this.len + required); } }
/** * Ensures that the capacity is at least equal to the specified minimum. * If the current capacity is less than the argument, then a new internal * array is allocated with greater capacity. If the {@code required} * argument is non-positive, this method takes no action. * * @param required the minimum required capacity. */ public void ensureCapacity(final int required) { if (required <= 0) { return; } final int available = this.array.length - this.len; if (required > available) { expand(this.len + required); } }
/** * Appends chars of the given string to this buffer. The capacity of the * buffer is increased, if necessary, to accommodate all chars. * * @param str the string. */ public void append(final String str) { final String s = str != null ? str : "null"; final int strlen = s.length(); final int newlen = this.len + strlen; if (newlen > this.array.length) { expand(newlen); } s.getChars(0, strlen, this.array, this.len); this.len = newlen; }
/** * Appends chars of the given string to this buffer. The capacity of the * buffer is increased, if necessary, to accommodate all chars. * * @param str the string. */ public void append(final String str) { final String s = str != null ? str : "null"; final int strlen = s.length(); final int newlen = this.len + strlen; if (newlen > this.array.length) { expand(newlen); } s.getChars(0, strlen, this.array, this.len); this.len = newlen; }
final int newlen = oldlen + len; if (newlen > this.array.length) { expand(newlen);
final int newlen = oldlen + len; if (newlen > this.array.length) { expand(newlen);
/** * Appends {@code len} chars to this buffer from the given source * array starting at index {@code off}. The capacity of the buffer * is increased, if necessary, to accommodate all {@code len} chars. * * @param b the chars to be appended. * @param off the index of the first char to append. * @param len the number of chars to append. * @throws IndexOutOfBoundsException if {@code off} is out of * range, {@code len} is negative, or * {@code off} + {@code len} is out of range. */ public void append(final char[] b, final int off, final int len) { if (b == null) { return; } if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) < 0) || ((off + len) > b.length)) { throw new IndexOutOfBoundsException("off: "+off+" len: "+len+" b.length: "+b.length); } if (len == 0) { return; } final int newlen = this.len + len; if (newlen > this.array.length) { expand(newlen); } System.arraycopy(b, off, this.array, this.len, len); this.len = newlen; }
/** * Appends {@code len} chars to this buffer from the given source * array starting at index {@code off}. The capacity of the buffer * is increased, if necessary, to accommodate all {@code len} chars. * * @param b the chars to be appended. * @param off the index of the first char to append. * @param len the number of chars to append. * @throws IndexOutOfBoundsException if {@code off} is out of * range, {@code len} is negative, or * {@code off} + {@code len} is out of range. */ public void append(final char[] b, final int off, final int len) { if (b == null) { return; } if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) < 0) || ((off + len) > b.length)) { throw new IndexOutOfBoundsException("off: "+off+" len: "+len+" b.length: "+b.length); } if (len == 0) { return; } final int newlen = this.len + len; if (newlen > this.array.length) { expand(newlen); } System.arraycopy(b, off, this.array, this.len, len); this.len = newlen; }