jodd.util.buffer
Class FastCharBuffer

java.lang.Object
  extended by jodd.util.buffer.FastCharBuffer
All Implemented Interfaces:
java.lang.Appendable, java.lang.CharSequence

public class FastCharBuffer
extends java.lang.Object
implements java.lang.CharSequence, java.lang.Appendable

Fast, fast char buffer with some additional features.


Constructor Summary
FastCharBuffer()
          Creates a new char buffer.
FastCharBuffer(int size)
          Creates a new char buffer, with a buffer capacity of the specified size, in bytes.
 
Method Summary
 FastCharBuffer append(char element)
          Appends single char to buffer.
 FastCharBuffer append(char[] array)
          Appends char array to buffer.
 FastCharBuffer append(char[] array, int off, int len)
          Appends char array to buffer.
 FastCharBuffer append(java.lang.CharSequence csq)
          Appends character sequence to buffer.
 FastCharBuffer append(java.lang.CharSequence csq, int start, int end)
          Appends character sequence to buffer.
 FastCharBuffer append(FastCharBuffer buff)
          Appends another fast buffer to this one.
 FastCharBuffer append(java.lang.String string)
          Appends string content to buffer.
 char[] array(int index)
          Returns char inner array chunk at given index.
 char charAt(int index)
          Returns char at given index.
 void clear()
          Resets the buffer content.
 char get(int index)
          Returns char element at given index.
 int index()
          Returns current index of inner char array chunk.
 boolean isEmpty()
          Tests if this buffer has no elements.
 int length()
          Returns buffer length, same as size().
 int offset()
          Returns the offset of last used element in current inner array chunk.
 int size()
          Returns buffer size.
 java.lang.CharSequence subSequence(int start, int end)
          Returns sub sequence.
 char[] toArray()
          Creates char array from buffered content.
 char[] toArray(int start, int len)
          Creates char subarray from buffered content.
 java.lang.String toString()
          Returns buffer content as a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FastCharBuffer

public FastCharBuffer()
Creates a new char buffer. The buffer capacity is initially 1024 bytes, though its size increases if necessary.


FastCharBuffer

public FastCharBuffer(int size)
Creates a new char buffer, with a buffer capacity of the specified size, in bytes.

Parameters:
size - the initial size.
Throws:
java.lang.IllegalArgumentException - if size is negative.
Method Detail

append

public FastCharBuffer append(char[] array,
                             int off,
                             int len)
Appends char array to buffer.


append

public FastCharBuffer append(char[] array)
Appends char array to buffer.


append

public FastCharBuffer append(char element)
Appends single char to buffer.

Specified by:
append in interface java.lang.Appendable

append

public FastCharBuffer append(FastCharBuffer buff)
Appends another fast buffer to this one.


size

public int size()
Returns buffer size.


isEmpty

public boolean isEmpty()
Tests if this buffer has no elements.


index

public int index()
Returns current index of inner char array chunk. Represents the index of last used inner array chunk.


offset

public int offset()
Returns the offset of last used element in current inner array chunk.


array

public char[] array(int index)
Returns char inner array chunk at given index. May be used for iterating inner chunks in fast manner.


clear

public void clear()
Resets the buffer content.


toArray

public char[] toArray()
Creates char array from buffered content.


toArray

public char[] toArray(int start,
                      int len)
Creates char subarray from buffered content.


get

public char get(int index)
Returns char element at given index.


length

public int length()
Returns buffer length, same as size().

Specified by:
length in interface java.lang.CharSequence

toString

public java.lang.String toString()
Returns buffer content as a string.

Specified by:
toString in interface java.lang.CharSequence
Overrides:
toString in class java.lang.Object

charAt

public char charAt(int index)
Returns char at given index.

Specified by:
charAt in interface java.lang.CharSequence

subSequence

public java.lang.CharSequence subSequence(int start,
                                          int end)
Returns sub sequence.

Specified by:
subSequence in interface java.lang.CharSequence

append

public FastCharBuffer append(java.lang.String string)
Appends string content to buffer.


append

public FastCharBuffer append(java.lang.CharSequence csq)
Appends character sequence to buffer.

Specified by:
append in interface java.lang.Appendable

append

public FastCharBuffer append(java.lang.CharSequence csq,
                             int start,
                             int end)
Appends character sequence to buffer.

Specified by:
append in interface java.lang.Appendable


Copyright © 2003-2012 Jodd Team