public final class TextBuffer
extends java.lang.Object
StringBuffer
, with
following differences:
Constructor and Description |
---|
TextBuffer(BufferRecycler allocator) |
Modifier and Type | Method and Description |
---|---|
void |
append(char c) |
void |
append(char[] c,
int start,
int len) |
void |
append(java.lang.String str,
int offset,
int len) |
char[] |
contentsAsArray() |
java.math.BigDecimal |
contentsAsDecimal()
Convenience method for converting contents of the buffer
into a
BigDecimal . |
double |
contentsAsDouble()
Convenience method for converting contents of the buffer
into a Double value.
|
int |
contentsAsInt(boolean neg)
Specialized convenience method that will decode a 32-bit int,
of at most 9 digits (and possible leading minus sign).
|
long |
contentsAsLong(boolean neg)
Specialized convenience method that will decode a 64-bit int,
of at most 18 digits (and possible leading minus sign).
|
java.lang.String |
contentsAsString() |
int |
contentsToWriter(java.io.Writer w) |
char[] |
emptyAndGetCurrentSegment() |
void |
ensureNotShared()
Method called to make sure that buffer is not using shared input
buffer; if it is, it will copy such contents to private buffer.
|
char[] |
expandCurrentSegment()
Method called to expand size of the current segment, to
accommodate for more contiguous content.
|
char[] |
expandCurrentSegment(int minSize)
Method called to expand size of the current segment, to
accommodate for more contiguous content.
|
char[] |
finishCurrentSegment() |
char[] |
getBufferWithoutReset() |
char[] |
getCurrentSegment() |
int |
getCurrentSegmentSize() |
char[] |
getTextBuffer()
Accessor that may be used to get the contents of this buffer in a single
char array regardless of whether they were collected in a segmented
fashion or not. |
int |
getTextOffset() |
boolean |
hasTextAsCharacters()
Method that can be used to check whether textual contents can
be efficiently accessed using
getTextBuffer() . |
void |
releaseBuffers()
Method called to indicate that the underlying buffers should now
be recycled if they haven't yet been recycled.
|
void |
resetWith(char ch) |
void |
resetWithCopy(char[] buf,
int start,
int len) |
void |
resetWithCopy(java.lang.String text,
int start,
int len) |
void |
resetWithEmpty()
Method called to clear out any content text buffer may have, and
initializes buffer to use non-shared data.
|
void |
resetWithShared(char[] buf,
int start,
int len)
Method called to initialize the buffer with a shared copy of data;
this means that buffer will just have pointers to actual data.
|
void |
resetWithString(java.lang.String value) |
java.lang.String |
setCurrentAndReturn(int len) |
void |
setCurrentLength(int len) |
int |
size() |
java.lang.String |
toString()
Note: calling this method may not be as efficient as calling
contentsAsString() , since it's not guaranteed that resulting
String is cached. |
public TextBuffer(BufferRecycler allocator)
public void releaseBuffers()
public void resetWithEmpty()
public void resetWith(char ch)
public void resetWithShared(char[] buf, int start, int len)
public void resetWithCopy(char[] buf, int start, int len)
public void resetWithCopy(java.lang.String text, int start, int len)
public void resetWithString(java.lang.String value)
public char[] getBufferWithoutReset()
public int size()
public int getTextOffset()
public boolean hasTextAsCharacters()
getTextBuffer()
.public char[] getTextBuffer()
char
array regardless of whether they were collected in a segmented
fashion or not.public java.lang.String contentsAsString()
public char[] contentsAsArray()
public java.math.BigDecimal contentsAsDecimal() throws java.lang.NumberFormatException
BigDecimal
.java.lang.NumberFormatException
public double contentsAsDouble() throws java.lang.NumberFormatException
java.lang.NumberFormatException
public int contentsAsInt(boolean neg)
neg
- Whether contents start with a minus signpublic long contentsAsLong(boolean neg)
neg
- Whether contents start with a minus signpublic int contentsToWriter(java.io.Writer w) throws java.io.IOException
java.io.IOException
public void ensureNotShared()
public void append(char c)
public void append(char[] c, int start, int len)
public void append(java.lang.String str, int offset, int len)
public char[] getCurrentSegment()
public char[] emptyAndGetCurrentSegment()
public int getCurrentSegmentSize()
public void setCurrentLength(int len)
public java.lang.String setCurrentAndReturn(int len)
public char[] finishCurrentSegment()
public char[] expandCurrentSegment()
public char[] expandCurrentSegment(int minSize)
minSize
- Required minimum strength of the current segmentpublic java.lang.String toString()
contentsAsString()
, since it's not guaranteed that resulting
String is cached.toString
in class java.lang.Object
"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"