Class FastStringBuffer

java.lang.Object
com.avoka.core.util.FastStringBuffer

public class FastStringBuffer extends Object
Provides a unsyncronized StringBuffer.

Synchronization

To improve performance in a thread safe environment this class does not synchronize append operations. Internally this class uses a character buffer adapted from the Click HtmlStringBuffer.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected char[]
    The character storage array.
    protected int
    The count is the number of characters used.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a new HTML StringBuffer with an initial capacity of 128 characters.
    FastStringBuffer(int length)
    Create a new HTML StringBuffer with the specified initial capacity.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    append(char value)
    Append the char value to the buffer.
    void
    append(int value)
    Append the integer value to the buffer.
    void
    append(long value)
    Append the long value to the buffer.
    void
    append(Object value)
    Append the raw object value of the given object to the buffer.
    void
    append(String value)
    Append the raw string value of the given object to the buffer.
    protected void
    expandCapacity(int minimumCapacity)
    Ensures that the capacity is at least equal to the specified minimum.
    int
    Return the length of the string buffer.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • characters

      protected char[] characters
      The character storage array.
    • count

      protected int count
      The count is the number of characters used.
  • Constructor Details

    • FastStringBuffer

      public FastStringBuffer(int length)
      Create a new HTML StringBuffer with the specified initial capacity.
      Parameters:
      length - the initial capacity
    • FastStringBuffer

      public FastStringBuffer()
      Create a new HTML StringBuffer with an initial capacity of 128 characters.
  • Method Details

    • append

      public void append(char value)
      Append the char value to the buffer.
      Parameters:
      value - the char value to append
    • append

      public void append(int value)
      Append the integer value to the buffer.
      Parameters:
      value - the integer value to append
    • append

      public void append(long value)
      Append the long value to the buffer.
      Parameters:
      value - the long value to append
    • append

      public void append(Object value)
      Append the raw object value of the given object to the buffer.
      Parameters:
      value - the object value to append
    • append

      public void append(String value)
      Append the raw string value of the given object to the buffer.
      Parameters:
      value - the string value to append
    • length

      public int length()
      Return the length of the string buffer.
      Returns:
      the length of the string buffer
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      a string representation of the string buffer
      See Also:
    • expandCapacity

      protected void expandCapacity(int minimumCapacity)
      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. The new capacity is the larger of:
      • The minimumCapacity argument.
      • Twice the old capacity, plus 2.
      If the minimumCapacity argument is nonpositive, this method takes no action and simply returns.
      Parameters:
      minimumCapacity - the minimum desired capacity