public static final class SegmentSequence.Builder
extends java.lang.Object
composed string
or a toSegmentSequence()
.
It may be a more efficient alternative to StringBuilder
because the strings are not copied to a character-based buffer until toString()
is called.
At that time, the total number of characters needed is known, so a character array can be allocated and used direct to create a string.
Using the empty string as the delimiter is particularly useful for that purpose.Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
delimiter
The delimiter of the builder.
|
protected int |
size
The number of strings in the builder.
|
protected java.lang.String[] |
strings
The string sin the builder.
|
Modifier | Constructor and Description |
---|---|
protected |
SegmentSequence.Builder(java.lang.String delimiter,
int capacity)
Creates an instance with the given capacity.
|
Modifier and Type | Method and Description |
---|---|
SegmentSequence.Builder |
append(char c)
Appends a string representation of the character to the builder and returns the builder itself.
|
SegmentSequence.Builder |
append(java.lang.String string)
Appends a string to the builder and returns the builder itself.
|
SegmentSequence.Builder |
reverse()
Reverses the strings in the builder and returns the builder itself.
|
SegmentSequence |
toSegmentSequence()
Converts the builder to a corresponding segment sequence.
|
java.lang.String |
toString()
Converts the builder to a string representation, i.e,. the delimiter-separated composition of the appended strings.
|
protected final java.lang.String delimiter
protected int size
protected java.lang.String[] strings
protected SegmentSequence.Builder(java.lang.String delimiter, int capacity)
public SegmentSequence.Builder append(java.lang.String string)
public SegmentSequence.Builder append(char c)
public SegmentSequence.Builder reverse()
public SegmentSequence toSegmentSequence()
public java.lang.String toString()
toString
in class java.lang.Object