Top Description Fields Constructors Methods
org.jdom.input

pack-priv Class TextBuffer

extends Object
Class Inheritance
Imports
org.jdom.*

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.
Authors
Bradley S. Huffman, Alex Rosen
Version
$Revision: 1.10 $, $Date: 2007/11/10 05:29:00 $

Field Summary

Modifier and TypeField and Description
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 final String
private String
prefixString

The first part of the text value (the "prefix").

Constructor Summary

AccessConstructor and Description
pack-priv
TextBuffer()

Constructor

Method Summary

Modifier and TypeMethod and Description
pack-priv void
append(char[] source, int start, int count)

Append the specified text to the text value of this buffer.

pack-priv void
clear()

Clears the text value and prepares the TextBuffer for reuse.

private void
ensureCapacity(int csize)

pack-priv boolean
pack-priv int
size()

Returns the size of the text value.

public String
toString()

Overrides java.lang.Object.toString.

Returns the text value stored in the buffer.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

arrayback to summary
private char[] array

The rest of the text value (the "suffix"). Only the first code>arraySize characters are valid.

arraySizeback to summary
private int arraySize

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

CVS_IDback to summary
private static final String CVS_ID
prefixStringback to summary
private String prefixString

The first part of the text value (the "prefix"). If null, the text value is the empty string.

Constructor Detail

TextBufferback to summary
pack-priv TextBuffer()

Constructor

Method Detail

appendback to summary
pack-priv void append(char[] source, int start, int count)

Append the specified text to the text value of this buffer.

clearback to summary
pack-priv void clear()

Clears the text value and prepares the TextBuffer for reuse.

ensureCapacityback to summary
private void ensureCapacity(int csize)
isAllWhitespaceback to summary
pack-priv boolean isAllWhitespace()
sizeback to summary
pack-priv int size()

Returns the size of the text value.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns the text value stored in the buffer.

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object.