/** * Writes single byte. */ @Override public void write(int b) { buffer.append((char) b); }
/** * Returns char at given index. */ public char charAt(int index) { return get(index); }
/** * Appends single <code>char</code> to buffer. */ public FastCharBuffer append(char element) { if ((currentBuffer == null) || (offset == currentBuffer.length)) { needNewBuffer(size + 1); } currentBuffer[offset] = element; offset++; size++; return this; }
/** * @see java.io.CharArrayWriter#toCharArray() */ public char[] toCharArray() { return buffer.toArray(); }
/** * @see java.io.CharArrayWriter#reset() */ public void reset() { buffer.clear(); }
/** * Creates a new char array writer, with a buffer capacity of * the specified size, in bytes. * * @param size the initial size. * @throws IllegalArgumentException if size is negative. */ public FastCharArrayWriter(int size) { buffer = new FastCharBuffer(size); }
/** * @see java.io.CharArrayWriter#size() */ public int size() { return buffer.size(); }
/** * Returns buffer content as a string. */ public String toString() { return new String(toArray()); }
/** * @see java.io.Writer#write(char[], int, int) */ @Override public void write(char[] b, int off, int len) { buffer.append(b, off, len); }
needNewBuffer(newSize);
/** * Returns sub sequence. */ public CharSequence subSequence(int start, int end) { int len = end - start; return new StringBuilder(len).append(toArray(start, len)); }
/** * Returns char at given index. */ public char charAt(int index) { return get(index); }
/** * Appends <code>char</code> array to buffer. */ public FastCharBuffer append(char[] array) { return append(array, 0, array.length); }
needNewBuffer(newSize);
/** * Returns buffer content as a string. */ public String toString() { return new String(toArray()); }
/** * Appends single <code>char</code> to buffer. */ public FastCharBuffer append(char element) { if ((currentBuffer == null) || (offset == currentBuffer.length)) { needNewBuffer(size + 1); } currentBuffer[offset] = element; offset++; size++; return this; }
/** * Returns sub sequence. */ public CharSequence subSequence(int start, int end) { int len = end - start; return new StringBuilder(len).append(toArray(start, len)); }
/** * Appends character sequence to buffer. */ public FastCharBuffer append(CharSequence csq, int start, int end) { for (int i = start; i < end; i++) { append(csq.charAt(i)); } return this; }