|
J avolution v3.7 (J2SE 1.5+) | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavolution.realtime.RealtimeObject
javolution.lang.TextBuilder
public class TextBuilder
This class represents an Appendable text whose capacity expands
gently without incurring expensive resize/copy operations ever.
This class is not intended for large documents manipulations which
should be performed with the Text class directly
(O(Log(n)) insertion and
deletion capabilities).
This implementation is not synchronized.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class javolution.realtime.RealtimeObject |
|---|
RealtimeObject.Factory<T extends RealtimeObject> |
| Nested classes/interfaces inherited from interface javolution.realtime.Realtime |
|---|
Realtime.ObjectSpace |
| Constructor Summary | |
|---|---|
TextBuilder()
Creates a text builder of small initial capacity. |
|
TextBuilder(java.lang.CharSequence csq)
Creates a text builder holding the specified character sequence. |
|
TextBuilder(int capacity)
Creates a text builder of specified initial capacity. |
|
| Method Summary | |
|---|---|
TextBuilder |
append(boolean b)
Appends the textual representation of the specified boolean
(equivalent to TypeFormat.format(b, this)). |
TextBuilder |
append(char c)
Appends the specified character. |
TextBuilder |
append(char[] chars)
Appends the characters from the char array argument. |
TextBuilder |
append(char[] chars,
int offset,
int length)
Appends the characters from a subarray of the char array argument. |
TextBuilder |
append(java.lang.CharSequence csq)
Appends the specified character sequence. |
TextBuilder |
append(java.lang.CharSequence csq,
int start,
int end)
Appends a subsequence of the specified character sequence. |
TextBuilder |
append(double d)
Appends the textual representation of the specified double
(equivalent to TypeFormat.format(d, this)). |
TextBuilder |
append(double value,
int digits,
boolean scientific,
boolean showZero)
Appends the specified double value according to the
specified formatting arguments. |
TextBuilder |
append(float f)
Appends the textual representation of the specified float
(equivalent to TypeFormat.format(f, this)). |
TextBuilder |
append(int i)
Appends the decimal representation of the specified int
(equivalent to TypeFormat.format(i, this)). |
TextBuilder |
append(int i,
int radix)
Appends the radix representation of the specified int
argument. |
TextBuilder |
append(long l)
Appends the decimal representation of the specified long
(equivalent to TypeFormat.format(l, this)). |
TextBuilder |
append(long l,
int radix)
Appends the radix representation of the specified long
argument. |
TextBuilder |
append(java.lang.Object obj)
Appends the textual representation of the specified object. |
TextBuilder |
append(java.lang.String str)
Appends the specified string to this text builder. |
TextBuilder |
append(java.lang.String str,
int start,
int end)
Appends a subsequence of the specified string. |
TextBuilder |
append(Text text)
Appends the specified text to this text builder. |
char |
charAt(int index)
Returns the character at the specified index. |
TextBuilder |
delete(int start,
int end)
Removes the characters between the specified indices. |
boolean |
equals(java.lang.Object obj)
Compares this text builder against the specified object for equality. |
void |
getChars(int srcBegin,
int srcEnd,
char[] dst,
int dstBegin)
Copies the character from this text builder into the destination character array. |
int |
hashCode()
Returns the hash code for this text builder. |
TextBuilder |
insert(int index,
java.lang.CharSequence csq)
Inserts the specified character sequence at the specified location. |
int |
length()
Returns the length (character count) of this text builder. |
static TextBuilder |
newInstance()
Returns a text builder allocated from the "stack" when executing in a PoolContext). |
void |
reset()
Resets this text builder for reuse (sets its length to 0). |
TextBuilder |
reverse()
Reverses this character sequence. |
void |
setCharAt(int index,
char c)
Sets the character at the specified position. |
void |
setLength(int newLength)
Sets the length of this character builder. |
java.lang.CharSequence |
subSequence(int start,
int end)
Returns an instance of Text (immutable) corresponding
to the character sequence between the specified indexes. |
Text |
toText()
Returns the Text corresponding to this TextBuilder
(allocated on the "stack" when executing in a
PoolContext). |
| Methods inherited from class javolution.realtime.RealtimeObject |
|---|
export, move, moveHeap, preserve, recycle, toString, unpreserve |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.lang.CharSequence |
|---|
toString |
| Constructor Detail |
|---|
public TextBuilder()
public TextBuilder(java.lang.CharSequence csq)
csq - the initial character sequence of this text builder.public TextBuilder(int capacity)
capacity - the initial capacity.| Method Detail |
|---|
public static TextBuilder newInstance()
PoolContext).
public final int length()
length in interface java.lang.CharSequencepublic final char charAt(int index)
charAt in interface java.lang.CharSequenceindex - the index of the character.
java.lang.IndexOutOfBoundsException - if (index < 0) ||
(index >= this.length()).
public final void getChars(int srcBegin,
int srcEnd,
char[] dst,
int dstBegin)
srcBegin - this text start index.srcEnd - this text end index (not included).dst - the destination array to copy the data into.dstBegin - the offset into the destination array.
java.lang.IndexOutOfBoundsException - if (srcBegin < 0) ||
(dstBegin < 0) || (srcBegin > srcEnd) || (srcEnd > this.length())
|| ((dstBegin + srcEnd - srcBegin) > dst.length)
public final void setCharAt(int index,
char c)
index - the index of the character to modify.c - the new character.
java.lang.IndexOutOfBoundsException - if (index < 0) ||
(index >= this.length())public final void setLength(int newLength)
'\u0000' is inserted.
newLength - the new length of this builder.
java.lang.IndexOutOfBoundsException - if (newLength < 0)
public final java.lang.CharSequence subSequence(int start,
int end)
Text (immutable) corresponding
to the character sequence between the specified indexes.
subSequence in interface java.lang.CharSequencestart - the index of the first character inclusive.end - the index of the last character exclusive.
java.lang.IndexOutOfBoundsException - if (start < 0) || (end < 0) ||
(start > end) || (end > this.length())public final TextBuilder append(char c)
append in interface java.lang.Appendablec - the character to append.
thispublic final TextBuilder append(java.lang.CharSequence csq)
null this method is equivalent to
append("null").
append in interface java.lang.Appendablecsq - the character sequence to append or null.
this
public final TextBuilder append(java.lang.CharSequence csq,
int start,
int end)
null this method
is equivalent to append("null").
append in interface java.lang.Appendablecsq - the character sequence to append or null.start - the index of the first character to append.end - the index after the last character to append.
this
java.lang.IndexOutOfBoundsException - if (start < 0) || (end < 0)
|| (start > end) || (end > csq.length())public final TextBuilder append(java.lang.Object obj)
null this method
is equivalent to append("null").
obj - the object to represent or null.
thispublic final TextBuilder append(java.lang.String str)
null this method
is equivalent to append("null").
str - the string to append or null.
this
public final TextBuilder append(java.lang.String str,
int start,
int end)
null this method
is equivalent to append("null").
str - the string to append or null.start - the index of the first character to append.end - the index after the last character to append.
this
java.lang.IndexOutOfBoundsException - if (start < 0) || (end < 0)
|| (start > end) || (end > csq.length())public TextBuilder append(Text text)
null this method
is equivalent to append("null").
text - the text to append or null.
thispublic final TextBuilder append(char[] chars)
chars - the character array source.
this
public final TextBuilder append(char[] chars,
int offset,
int length)
chars - the character array source.offset - the index of the first character to append.length - the number of character to append.
this
java.lang.IndexOutOfBoundsException - if (offset < 0) ||
(length < 0) || ((offset + length) > chars.length)public final TextBuilder append(boolean b)
boolean
(equivalent to TypeFormat.format(b, this)).
b - the boolean to format.
thisTypeFormatpublic final TextBuilder append(int i)
int
(equivalent to TypeFormat.format(i, this)).
i - the int to format.
thisTypeFormat
public final TextBuilder append(int i,
int radix)
int
argument.
i - the int to format.radix - the radix (e.g. 16 for hexadecimal).
thisTypeFormatpublic final TextBuilder append(long l)
long
(equivalent to TypeFormat.format(l, this)).
l - the long to format.
thisTypeFormat
public final TextBuilder append(long l,
int radix)
long
argument.
l - the long to format.radix - the radix (e.g. 16 for hexadecimal).
thisTypeFormatpublic final TextBuilder append(float f)
float
(equivalent to TypeFormat.format(f, this)).
f - the float to format.
this/public final TextBuilder append(double d)
double
(equivalent to TypeFormat.format(d, this)).
d - the double to format.
this/
public final TextBuilder append(double value,
int digits,
boolean scientific,
boolean showZero)
double value according to the
specified formatting arguments.
value - the double value.digits - the number of significative digits (excludes exponent).scientific - true to forces the use of the scientific
notation (e.g. 1.23E3); false
otherwise.showZero - true if trailing fractional zeros are
represented; false otherwise.
this
java.lang.IllegalArgumentException - if ((digits > 19) ||
(digits <= 0)))
/
public final TextBuilder insert(int index,
java.lang.CharSequence csq)
index - the insertion position.csq - the character sequence being inserted.
this
java.lang.IndexOutOfBoundsException - if (index < 0) ||
(index > this.length())
public final TextBuilder delete(int start,
int end)
start - the beginning index, inclusive.end - the ending index, exclusive.
this
java.lang.IndexOutOfBoundsException - if (start < 0) || (end < 0)
|| (start > end) || (end > this.length())public final TextBuilder reverse()
thispublic final Text toText()
Text corresponding to this TextBuilder
(allocated on the "stack" when executing in a
PoolContext).
toText in interface RealtimetoText in class RealtimeObjectText instance.public final void reset()
0).
reset in interface Reusablepublic final int hashCode()
hashCode in class java.lang.Objectpublic final boolean equals(java.lang.Object obj)
true if the specified object is a text builder
having the same character content.
equals in class java.lang.Objectobj - the object to compare with or null.
true if that is a text builder with the same
character content as this text; false otherwise.
|
J avolution v3.7 (J2SE 1.5+) | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||