Klasse CharArrayBuffer

java.lang.Object
org.aspectj.org.eclipse.jdt.internal.core.util.CharArrayBuffer

public class CharArrayBuffer extends Object
The CharArrayBuffer is intended as a lightweight partial implementation of the StringBuffer class, but using char[]'s instead of Strings.

The CharArrayBuffer maintains a list of char[]'s which don't get appended until the user asks for them. The following code illustrates how to use the class. CharArrayBuffer buffer = new CharArrayBuffer(myCharArray); buffer.append(moreBytes, 0, someLength); myCharArray = buffer.getContents();

NOTE: This class is not Thread safe!

  • Feldübersicht

    Felder
    Modifizierer und Typ
    Feld
    Beschreibung
    protected char[][]
    This is the buffer of char arrays which must be appended together during the getContents method.
    static final int
    The default buffer size.
    protected int
    The end of the buffer
    protected int[][]
    A buffer of ranges which is maintained along with the buffer.
    protected int
    The current size of the buffer.
  • Konstruktorübersicht

    Konstruktoren
    Konstruktor
    Beschreibung
    Creates a CharArrayBuffer with the default buffer size (10).
    CharArrayBuffer(char[] first)
    Creates a CharArrayBuffer with the default buffer size, and sets the first element in the buffer to be the given char[].
    CharArrayBuffer(char[] first, int size)
    Creates a CharArrayBuffer with the given buffer size, and sets the first element in the buffer to be the given char array.
    CharArrayBuffer(int size)
    Creates a CharArrayBuffer with the given buffer size.
  • Methodenübersicht

    Modifizierer und Typ
    Methode
    Beschreibung
    append(char c)
    Appends the given char.
    append(char[] src)
    Appends the entire given char array.
    append(char[] src, int start, int length)
    Appends a sub array of the given array to the buffer.
    Appends the given String to the buffer.
    char[]
    Returns the entire contents of the buffer as one char[] or null if nothing has been put in the buffer.
    Returns the contents of the buffer as a String, or an empty string if the buffer is empty.

    Von Klasse geerbte Methoden java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Felddetails

    • buffer

      protected char[][] buffer
      This is the buffer of char arrays which must be appended together during the getContents method.
    • DEFAULT_BUFFER_SIZE

      public static final int DEFAULT_BUFFER_SIZE
      The default buffer size.
      Siehe auch:
    • end

      protected int end
      The end of the buffer
    • size

      protected int size
      The current size of the buffer.
    • ranges

      protected int[][] ranges
      A buffer of ranges which is maintained along with the buffer. Ranges are of the form {start, length}. Enables append(char[] array, int start, int end).
  • Konstruktordetails

    • CharArrayBuffer

      public CharArrayBuffer()
      Creates a CharArrayBuffer with the default buffer size (10).
    • CharArrayBuffer

      public CharArrayBuffer(char[] first)
      Creates a CharArrayBuffer with the default buffer size, and sets the first element in the buffer to be the given char[].
      Parameter:
      first - - the first element to be placed in the buffer, ignored if null
    • CharArrayBuffer

      public CharArrayBuffer(char[] first, int size)
      Creates a CharArrayBuffer with the given buffer size, and sets the first element in the buffer to be the given char array.
      Parameter:
      first - - the first element of the buffer, ignored if null.
      size - - the buffer size, if less than 1, set to the DEFAULT_BUFFER_SIZE.
    • CharArrayBuffer

      public CharArrayBuffer(int size)
      Creates a CharArrayBuffer with the given buffer size.
      Parameter:
      size - - the size of the buffer.
  • Methodendetails

    • append

      public CharArrayBuffer append(char[] src)
      Appends the entire given char array. Given for convenience.
      Parameter:
      src - - a char array which is appended to the end of the buffer.
    • append

      public CharArrayBuffer append(char[] src, int start, int length)
      Appends a sub array of the given array to the buffer.
      Parameter:
      src - - the next array of characters to be appended to the buffer, ignored if null
      start - - the start index in the src array.
      length - - the number of characters from start to be appended
      Löst aus:
      ArrayIndexOutOfBoundsException - - if arguments specify an array index out of bounds.
    • append

      public CharArrayBuffer append(char c)
      Appends the given char. Given for convenience.
      Parameter:
      c - - a char which is appended to the end of the buffer.
    • append

      public CharArrayBuffer append(String src)
      Appends the given String to the buffer. Given for convenience, use #append(char[]) if possible
      Parameter:
      src - - a char array which is appended to the end of the buffer.
    • getContents

      public char[] getContents()
      Returns the entire contents of the buffer as one char[] or null if nothing has been put in the buffer.
    • toString

      public String toString()
      Returns the contents of the buffer as a String, or an empty string if the buffer is empty.
      Setzt außer Kraft:
      toString in Klasse Object