Top Description Fields Constructors Methods
org.jdom2.input.sax

pack-priv final Class TextBuffer

extends Object
Class Inheritance
Imports
org.jdom2.Verifier, org.jdom2.internal.ArrayCopy

A non-public utility class similar to StringBuilder 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 StringBuilder 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 StringBuilder means that no extra unused char array space will be kept around after parsing is through.
Authors
Bradley S. Huffman, Alex Rosen

Field Summary

Modifier and TypeField and Description
private char[]
array

The text value.

private int
arraySize

The size of the text value.

Constructor Summary

AccessConstructor and Description
pack-priv
TextBuffer()

Constructor

Method Summary

Modifier and TypeMethod and Description
pack-priv void
append(final char[]
The char[] data to add
source
,
final int
The offset in the data to start adding from
start
,
final int
The number of chars to add.
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.

pack-priv boolean

Returns:

true if all chars are whitespace
isAllWhitespace
()

Inspects the character data for non-whitespace

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 text value. Only the first arraySize characters are valid.

arraySizeback to summary
private int arraySize

The size of the text value.

Constructor Detail

TextBufferback to summary
pack-priv TextBuffer()

Constructor

Method Detail

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

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

Parameters
source:char[]

The char[] data to add

start:int

The offset in the data to start adding from

count:int

The number of chars to add.

clearback to summary
pack-priv void clear()

Clears the text value and prepares the TextBuffer for reuse.

isAllWhitespaceback to summary
pack-priv boolean isAllWhitespace()

Inspects the character data for non-whitespace

Returns:boolean

true if all chars are whitespace

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.

Annotations
@Override