Class 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[] characters
      The character storage array.
      protected int count
      The count is the number of characters used.
    • Constructor Summary

      Constructors 
      Constructor Description
      FastStringBuffer()
      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.
    • Field Detail

      • characters

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

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

      • 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 Detail

      • 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
      • 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