|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjodd.util.StringBand
public class StringBand
StringBand is a faster alternative to StringBuilder.
Instead of adding strings, they are stored in internal array. Only at the
end of concatenation, when toString is invoked, strings are
joined together.
To make StringBand even faster, predict the number of joined
strings (and not the final string size)!
| Constructor Summary | |
|---|---|
StringBand()
Creates an empty StringBand. |
|
StringBand(int initialCapacity)
Creates an empty StringBand with provided capacity. |
|
StringBand(java.lang.Object o)
|
|
StringBand(java.lang.String s)
Creates StringBand with provided content. |
|
| Method Summary | |
|---|---|
StringBand |
append(boolean b)
Appends boolean value. |
StringBand |
append(byte b)
Appends byte value. |
StringBand |
append(char c)
Appends a character. |
StringBand |
append(double d)
Appends double value. |
StringBand |
append(float f)
Appends float value. |
StringBand |
append(int i)
Appends int value. |
StringBand |
append(long l)
Appends long value. |
StringBand |
append(java.lang.Object obj)
Appends string representation of an object. |
StringBand |
append(short s)
Appends short value. |
StringBand |
append(java.lang.String s)
Appends a string. |
protected int |
calculateLength()
Calculates string length. |
int |
capacity()
Returns array capacity. |
char |
charAt(int pos)
Returns char at given position. |
protected void |
expandCapacity()
Expands internal string array by multiplying its size by 2. |
int |
index()
Returns current index of string array. |
int |
length()
Returns total string length. |
void |
setIndex(int newIndex)
Specifies the new index. |
java.lang.String |
stringAt(int index)
Returns string at given position. |
java.lang.String |
toString()
Joins together all strings into one. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public StringBand()
StringBand.
public StringBand(int initialCapacity)
StringBand with provided capacity.
Capacity refers to internal string array (i.e. number of
joins) and not the total string size.
public StringBand(java.lang.String s)
StringBand with provided content.
public StringBand(java.lang.Object o)
| Method Detail |
|---|
public StringBand append(boolean b)
public StringBand append(double d)
public StringBand append(float f)
public StringBand append(int i)
public StringBand append(long l)
public StringBand append(short s)
public StringBand append(char c)
StringBuilder, since new string is created.
public StringBand append(byte b)
public StringBand append(java.lang.Object obj)
null, the 'null' string
will be appended.
public StringBand append(java.lang.String s)
public int capacity()
public int length()
public int index()
public void setIndex(int newIndex)
public char charAt(int pos)
public java.lang.String stringAt(int index)
public java.lang.String toString()
toString in class java.lang.Objectprotected void expandCapacity()
protected int calculateLength()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||