DthingApi
|
Public Member Functions | |
StringBuffer () | |
StringBuffer (int capacity) | |
StringBuffer (String string) | |
StringBuffer | append (boolean b) |
synchronized StringBuffer | append (char ch) |
StringBuffer | append (double d) |
StringBuffer | append (float f) |
StringBuffer | append (int i) |
StringBuffer | append (long l) |
synchronized StringBuffer | append (Object obj) |
synchronized StringBuffer | append (String string) |
synchronized StringBuffer | append (StringBuffer sb) |
synchronized StringBuffer | append (char[] chars) |
synchronized StringBuffer | append (char[] chars, int start, int length) |
int | capacity () |
char | charAt (int index) |
synchronized StringBuffer | delete (int start, int end) |
synchronized StringBuffer | deleteCharAt (int location) |
synchronized void | ensureCapacity (int min) |
synchronized void | getChars (int start, int end, char[] buffer, int idx) |
synchronized int | indexOf (String subString, int start) |
synchronized StringBuffer | insert (int index, char ch) |
StringBuffer | insert (int index, boolean b) |
StringBuffer | insert (int index, int i) |
StringBuffer | insert (int index, long l) |
StringBuffer | insert (int index, double d) |
StringBuffer | insert (int index, float f) |
StringBuffer | insert (int index, Object obj) |
synchronized StringBuffer | insert (int index, String string) |
synchronized StringBuffer | insert (int index, char[] chars) |
synchronized StringBuffer | insert (int index, char[] chars, int start, int length) |
int | lastIndexOf (String string) |
synchronized int | lastIndexOf (String subString, int start) |
int | length () |
synchronized StringBuffer | replace (int start, int end, String string) |
synchronized StringBuffer | reverse () |
synchronized void | setCharAt (int index, char ch) |
synchronized void | setLength (int length) |
synchronized String | substring (int start) |
synchronized String | substring (int start, int end) |
synchronized String | toString () |
A modifiable sequence of characters for use in creating strings, where all accesses are synchronized. This class has mostly been replaced by StringBuilder because this synchronization is rarely useful. This class is mainly used to interact with legacy APIs that expose it.
For particularly complex string-building needs, consider java.util.Formatter.
The majority of the modification methods on this class return
so that method calls can be chained together. For example:
.
|
inline |
Constructs a new StringBuffer using the default capacity which is 16.
|
inline |
Constructs a new StringBuffer using the specified capacity.
capacity | the initial capacity. |
|
inline |
Constructs a new StringBuffer containing the characters in the specified string. The capacity of the new buffer will be the length of the
plus the default capacity.
string | the string content with which to initialize the new instance. |
NullPointerException | if string null |
|
inline |
Adds the string representation of the specified boolean to the end of this StringBuffer.
If the argument is
the string
is appended, otherwise the string
is appended.
b | the boolean to append. |
|
inline |
Adds the specified character to the end of this buffer.
ch | the character to append. |
|
inline |
Adds the string representation of the specified double to the end of this StringBuffer.
d | the double to append. |
|
inline |
Adds the string representation of the specified float to the end of this StringBuffer.
f | the float to append. |
|
inline |
Adds the string representation of the specified integer to the end of this StringBuffer.
i | the integer to append. |
|
inline |
Adds the string representation of the specified long to the end of this StringBuffer.
l | the long to append. |
|
inline |
Adds the string representation of the specified object to the end of this StringBuffer.
If the specified object is
the string
is appended, otherwise the objects
is used to get its string representation.
obj | the object to append (may be null). |
|
inline |
Adds the specified string to the end of this buffer.
If the specified string is
the string
is appended, otherwise the contents of the specified string is appended.
string | the string to append (may be null). |
|
inline |
Adds the specified StringBuffer to the end of this buffer.
If the specified StringBuffer is
the string
is appended, otherwise the contents of the specified StringBuffer is appended.
sb | the StringBuffer to append (may be null). |
|
inline |
Adds the character array to the end of this buffer.
chars | the character array to append. |
NullPointerException | if chars null |
|
inline |
Adds the specified sequence of characters to the end of this buffer.
chars | the character array to append. |
start | the starting offset. |
length | the number of characters. |
ArrayIndexOutOfBoundsException | if length < 0 start < 0 start + length > chars.length |
NullPointerException | if chars null |
|
inline |
Returns the current capacity of the String buffer. The capacity is the amount of storage available for newly inserted characters; beyond which an allocation will occur.
|
inline |
The specified character of the sequence currently represented by the string buffer, as indicated by the index
argument, is returned. The first character of a string buffer is at index 0
, the next at index 1
, and so on, for array indexing.
The index argument must be greater than or equal to 0
, and less than the length of this string buffer.
index | the index of the desired character. |
IndexOutOfBoundsException | if index is negative or greater than or equal to length() . |
|
inline |
Deletes a range of characters.
start | the offset of the first character. |
end | the offset one past the last character. |
StringIndexOutOfBoundsException | if start < 0 start > end end > length() |
|
inline |
Deletes the character at the specified offset.
location | the offset of the character to delete. |
StringIndexOutOfBoundsException | if location < 0 location >= length() |
|
inline |
Ensures that the capacity of the buffer is at least equal to the specified minimum. If the current capacity of this string buffer is less than the argument, then a new internal buffer is allocated with greater capacity. The new capacity is the larger of:
minimumCapacity
argument. 2
. If the minimumCapacity
argument is nonpositive, this method takes no action and simply returns.
minimumCapacity | the minimum desired capacity. |
|
inline |
Copies the requested sequence of characters to the
passed starting at
.
start | the starting offset of characters to copy. |
end | the ending offset of characters to copy. |
buffer | the destination character array. |
idx | the starting offset in the character array. |
IndexOutOfBoundsException | if start < 0 end > length() start > end index < 0 end - start > buffer.length - index |
|
inline |
Returns the index within this string of the first occurrence of the specified substring, starting at the specified index. The integer returned is the smallest value k
for which:
k >= Math.min(fromIndex, str.length()) && this.toString().startsWith(str, k)
If no such value of k exists, then -1 is returned.
str | the substring for which to search. |
fromIndex | the index from which to start the search. |
java.lang.NullPointerException | if str is null . |
|
inline |
Inserts the character into this buffer at the specified offset.
index | the index at which to insert. |
ch | the character to insert. |
ArrayIndexOutOfBoundsException | if index < 0 index > length() |
|
inline |
Inserts the string representation of the specified boolean into this buffer at the specified offset.
index | the index at which to insert. |
b | the boolean to insert. |
StringIndexOutOfBoundsException | if index < 0 index > length() |
|
inline |
Inserts the string representation of the specified integer into this buffer at the specified offset.
index | the index at which to insert. |
i | the integer to insert. |
StringIndexOutOfBoundsException | if index < 0 index > length() |
|
inline |
Inserts the string representation of the specified long into this buffer at the specified offset.
index | the index at which to insert. |
l | the long to insert. |
StringIndexOutOfBoundsException | if index < 0 index > length() |
|
inline |
Inserts the string representation of the specified into this buffer double at the specified offset.
index | the index at which to insert. |
d | the double to insert. |
StringIndexOutOfBoundsException | if index < 0 index > length() |
|
inline |
Inserts the string representation of the specified float into this buffer at the specified offset.
index | the index at which to insert. |
f | the float to insert. |
StringIndexOutOfBoundsException | if index < 0 index > length() |
|
inline |
Inserts the string representation of the specified object into this buffer at the specified offset.
If the specified object is
, the string
is inserted, otherwise the objects
method is used to get its string representation.
index | the index at which to insert. |
obj | the object to insert (may be null). |
StringIndexOutOfBoundsException | if index < 0 index > length() |
|
inline |
Inserts the string into this buffer at the specified offset.
If the specified string is
, the string
is inserted, otherwise the contents of the string is inserted.
index | the index at which to insert. |
string | the string to insert (may be null). |
StringIndexOutOfBoundsException | if index < 0 index > length() |
|
inline |
Inserts the character array into this buffer at the specified offset.
index | the index at which to insert. |
chars | the character array to insert. |
StringIndexOutOfBoundsException | if index < 0 index > length() |
NullPointerException | if chars null |
|
inline |
Inserts the specified subsequence of characters into this buffer at the specified index.
index | the index at which to insert. |
chars | the character array to insert. |
start | the starting offset. |
length | the number of characters. |
NullPointerException | if chars null |
StringIndexOutOfBoundsException | if length < 0 start < 0 start + length > chars.length index < 0 index > length() |
|
inline |
Returns the index within this string of the rightmost occurrence of the specified substring. The rightmost empty string "" is considered to occur at the index value this.length()
. The returned index is the largest value k such that
this.toString().startsWith(str, k)
is true.
str | the substring to search for. |
-1
is returned. java.lang.NullPointerException | if str is null . |
|
inline |
Returns the index within this string of the last occurrence of the specified substring. The integer returned is the largest value k such that:
k <= Math.min(fromIndex, str.length()) && this.toString().startsWith(str, k)
If no such value of k exists, then -1 is returned.
str | the substring to search for. |
fromIndex | the index to start the search from. |
java.lang.NullPointerException | if str is null . |
|
inline |
Returns the length of this string. The length is equal to the number of 16-bit Unicode characters in the string.
|
inline |
Replaces the characters in the specified range with the contents of the specified string.
start | the inclusive begin index. |
end | the exclusive end index. |
string | the string that will replace the contents in the range. |
StringIndexOutOfBoundsException | if start end start end end s |
|
inline |
Reverses the order of characters in this buffer.
|
inline |
The specified character of the sequence currently represented by the string buffer, as indicated by the index
argument, is returned. The first character of a string buffer is at index 0
, the next at index 1
, and so on, for array indexing.
The index argument must be greater than or equal to 0
, and less than the length of this string buffer.
index | the index of the desired character. |
IndexOutOfBoundsException | if index is negative or greater than or equal to length() . |
|
inline |
Sets the length of this String buffer. This string buffer is altered to represent a new character sequence whose length is specified by the argument. For every nonnegative index k less than newLength
, the character at index k in the new character sequence is the same as the character at index k in the old sequence if k is less than the length of the old character sequence; otherwise, it is the null character ''
.
In other words, if the newLength
argument is less than the current length of the string buffer, the string buffer is truncated to contain exactly the number of characters given by the newLength
argument.
If the newLength
argument is greater than or equal to the current length, sufficient null characters ('\u0000'
) are appended to the string buffer so that length becomes the newLength
argument.
The newLength
argument must be greater than or equal to 0
.
newLength | the new length of the buffer. |
StringIndexOutOfBoundsException | if the newLength argument is negative. |
|
inline |
Returns a new String
that contains a subsequence of characters currently contained in this StringBuffer
.The substring begins at the specified index and extends to the end of the StringBuffer
.
start | The beginning index, inclusive. |
StringIndexOutOfBoundsException | if start is less than zero, or greater than the length of this StringBuffer . |
|
inline |
Returns a new String
that contains a subsequence of characters currently contained in this StringBuffer
. The substring begins at the specified start
and extends to the character at index end - 1
. An exception is thrown if
start | The beginning index, inclusive. |
end | The ending index, exclusive. |
StringIndexOutOfBoundsException | if start or end are negative or greater than length() , or start is greater than end . |
|
inline |
Converts to a string representing the data in this string buffer. A new String
object is allocated and initialized to contain the character sequence currently represented by this string buffer. This String
is then returned. Subsequent changes to the string buffer do not affect the contents of the String
.
Implementation advice: This method can be coded so as to create a new String
object without allocating new memory to hold a copy of the character sequence. Instead, the string can share the memory used by the string buffer. Any subsequent operation that alters the content or capacity of the string buffer must then make a copy of the internal buffer at that time. This strategy is effective for reducing the amount of memory allocated by a string concatenation operation when it is implemented using a string buffer.