public class CompoundStringBuilder
extends java.lang.Object
StringBuilder
.Modifier and Type | Field and Description |
---|---|
protected java.lang.StringBuilder |
buffer |
protected int |
capacity |
protected int |
count |
protected static int |
DEFAULT_INITIAL_CAPACITY |
protected int[] |
lengths |
protected int[] |
offsets |
Constructor and Description |
---|
CompoundStringBuilder()
Constructs a CompoundStringBuilder with a default backing StringBuilder, and the default initial capacity.
|
CompoundStringBuilder(int capacity)
Constructs a CompoundStringBuilder with a default backing StringBuilder, and the specified initial capacity.
|
CompoundStringBuilder(java.lang.StringBuilder stringBuilder,
int capacity)
Constructs a CompoundStringBuilder with the specified backing StringBuilder and initial capacity.
|
Modifier and Type | Method and Description |
---|---|
int |
append(java.lang.CharSequence charSequence)
Appends the contents of the specified substring to the end of this CompoundStringBuilder, incrementing the number
of substrings by one.
|
void |
clear()
Clears this CompoundStringBuilder's backing StringBuilder and sets the number of substrings to zero.
|
protected void |
expandCapacity(int minCapacity) |
int |
size()
Returns the number of strings stored in this CompoundStringBuilder.
|
java.lang.CharSequence |
subSequence(int index)
Returns the substring at the specified index as a
CharSequence . |
java.lang.String |
substring(int index)
Returns the substring at the specified index as a
String . |
int |
substringLength(int index)
Returns the length of the substring with the specified index.
|
protected java.lang.StringBuilder buffer
protected int capacity
protected int count
protected static final int DEFAULT_INITIAL_CAPACITY
protected int[] lengths
protected int[] offsets
public CompoundStringBuilder()
public CompoundStringBuilder(int capacity)
capacity
- the compound buffer's initial capacity.java.lang.IllegalArgumentException
- if the capacity is less than 1.public CompoundStringBuilder(java.lang.StringBuilder stringBuilder, int capacity)
stringBuilder
- the StringBuilder in which to store the string data.capacity
- the compound buffer's initial capacity.java.lang.IllegalArgumentException
- if the stringBuilder is null or if the capacity is less than 1.public int append(java.lang.CharSequence charSequence)
charSequence
- the substring to append.java.lang.IllegalArgumentException
- if the charSequence is null.public void clear()
protected void expandCapacity(int minCapacity)
public int size()
public java.lang.CharSequence subSequence(int index)
CharSequence
.index
- the index of the substring to return.java.lang.IllegalArgumentException
- if the index is out of range.public java.lang.String substring(int index)
String
.index
- the index of the substring to return.java.lang.IllegalArgumentException
- if the index is out of range.public int substringLength(int index)
index
- the index for the substring who's length is returned.java.lang.IllegalArgumentException
- if the index is out of range.