public final class TextBuilder extends Object
StringBuilder
, but
that allows for bit more efficient building, using segmented internal
buffers, and direct access to these buffers.Modifier and Type | Field and Description |
---|---|
static int |
MAX_INDENT_SPACES |
static int |
MAX_INDENT_TABS |
Modifier and Type | Method and Description |
---|---|
void |
append(char c) |
void |
append(char[] c,
int start,
int len) |
void |
append(String str) |
void |
appendSurrogate(int surr) |
char[] |
contentsAsArray() |
String |
contentsAsString() |
int |
contentsToArray(int srcStart,
char[] dst,
int dstStart,
int len) |
static TextBuilder |
createRecyclableBuffer(ReaderConfig cfg) |
int |
decodeElements(org.codehaus.stax2.typed.TypedArrayDecoder tad,
boolean reset)
Method called by the stream reader to decode space-separated tokens
that are part of the current text event (contents of which
are stored within this buffer), using given decoder.
|
boolean |
endsWith(String str)
Method that can be used to check if the contents of the buffer end
in specified String.
|
boolean |
equalsString(String str)
Note: it is assumed that this method is not used often enough to
be a bottleneck, or for long segments.
|
char[] |
finishCurrentSegment() |
void |
fireSaxCharacterEvents(ContentHandler h)
This is a specialized "accessor" method, which is basically
to fire SAX characters() events in an optimal way, based on
which internal buffers are being used
|
void |
fireSaxCommentEvent(LexicalHandler h) |
void |
fireSaxSpaceEvents(ContentHandler h) |
char[] |
getBufferWithoutReset() |
int |
getCurrentLength() |
char[] |
getTextBuffer() |
boolean |
isAllWhitespace() |
int |
rawContentsTo(Writer w)
Method that will stream contents of this buffer into specified
Writer.
|
void |
recycle(boolean force)
Method called to indicate that the underlying buffers should now
be recycled if they haven't yet been recycled.
|
void |
resetForBinaryDecode(org.codehaus.stax2.typed.Base64Variant v,
org.codehaus.stax2.ri.typed.CharArrayBase64Decoder dec,
boolean firstChunk)
Method called to initialize given base64 decoder with data
contained in this text buffer (for the current event).
|
void |
resetWithChar(char c)
Method called to initialize the buffer with just a single char
|
char[] |
resetWithEmpty()
Method called to clear out any content text buffer may have, and
initializes and returns the first segment to add characters to.
|
void |
resetWithIndentation(int indCharCount,
char indChar) |
void |
resetWithSurrogate(int c) |
void |
setCurrentLength(int len) |
int |
size() |
String |
toString()
Note: calling this method may not be as efficient as calling
contentsAsString() , since it is guaranteed that resulting
String is NOT cached (to ensure we see no stale data) |
public static final int MAX_INDENT_SPACES
public static final int MAX_INDENT_TABS
public static TextBuilder createRecyclableBuffer(ReaderConfig cfg)
public void recycle(boolean force)
public char[] resetWithEmpty()
public void resetWithIndentation(int indCharCount, char indChar)
public void resetWithChar(char c)
public void resetWithSurrogate(int c)
public char[] getBufferWithoutReset()
public int size()
public char[] getTextBuffer()
public String contentsAsString()
public char[] contentsAsArray()
public int contentsToArray(int srcStart, char[] dst, int dstStart, int len)
public int rawContentsTo(Writer w) throws IOException
IOException
public boolean isAllWhitespace()
public boolean endsWith(String str)
public boolean equalsString(String str)
public void fireSaxCharacterEvents(ContentHandler h) throws SAXException
SAXException
public void fireSaxSpaceEvents(ContentHandler h) throws SAXException
SAXException
public void fireSaxCommentEvent(LexicalHandler h) throws SAXException
SAXException
public void append(char c)
public void appendSurrogate(int surr)
public void append(char[] c, int start, int len)
public void append(String str)
public int getCurrentLength()
public void setCurrentLength(int len)
public char[] finishCurrentSegment()
public int decodeElements(org.codehaus.stax2.typed.TypedArrayDecoder tad, boolean reset) throws org.codehaus.stax2.typed.TypedXMLStreamException
org.codehaus.stax2.typed.TypedXMLStreamException
public void resetForBinaryDecode(org.codehaus.stax2.typed.Base64Variant v, org.codehaus.stax2.ri.typed.CharArrayBase64Decoder dec, boolean firstChunk)
public String toString()
contentsAsString()
, since it is guaranteed that resulting
String is NOT cached (to ensure we see no stale data)Copyright © 2018 FasterXML. All rights reserved.