Class TextBuffer

java.lang.Object
  extended by TextBuffer

 class TextBuffer
extends java.lang.Object

A non-public utility class similar to StringBuffer but optimized for XML parsing where the common case is that you get only one chunk of characters per text section. TextBuffer stores the first chunk of characters in a String, which can just be returned directly if no second chunk is received. Subsequent chunks are stored in a supplemental char array (like StringBuffer uses). In this case, the returned text will be the first String chunk, concatenated with the subsequent chunks stored in the char array. This provides optimal performance in the common case, while still providing very good performance in the uncommon case. Furthermore, avoiding StringBuffer means that no extra unused char array space will be kept around after parsing is through.


Field Summary
private  char[] array
          The rest of the text value (the "suffix").
private  int arraySize
          The size of the rest of the text value.
private static java.lang.String CVS_ID
           
private  java.lang.String prefixString
          The first part of the text value (the "prefix").
 
Constructor Summary
TextBuffer()
          Constructor
 
Method Summary
(package private)  void append(char[] source, int start, int count)
          Append the specified text to the text value of this buffer.
(package private)  void clear()
          Clears the text value and prepares the TextBuffer for reuse.
private  void ensureCapacity(int csize)
           
(package private)  int size()
          Returns the size of the text value.
 java.lang.String toString()
          Returns the text value stored in the buffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CVS_ID

private static final java.lang.String CVS_ID
See Also:
Constant Field Values

prefixString

private java.lang.String prefixString
The first part of the text value (the "prefix"). If null, the text value is the empty string.


array

private char[] array
The rest of the text value (the "suffix"). Only the first code>arraySize characters are valid.


arraySize

private int arraySize
The size of the rest of the text value. If zero, then only code>prefixString contains the text value.

Constructor Detail

TextBuffer

TextBuffer()
Constructor

Method Detail

append

void append(char[] source,
            int start,
            int count)
Append the specified text to the text value of this buffer.


size

int size()
Returns the size of the text value.


clear

void clear()
Clears the text value and prepares the TextBuffer for reuse.


toString

public java.lang.String toString()
Returns the text value stored in the buffer.

Overrides:
toString in class java.lang.Object

ensureCapacity

private void ensureCapacity(int csize)