public final class StringObject extends Object
"a" + 4 + "c"
is compiled to:
new StringBuffer().append("a").append(4).append("c").toString()
Note that the method toString() does not create a copy of the internal buffer. Instead
the buffer is marked as shared. Any further changes to the buffer will
cause a copy to be made. this is based on StringBuffer code, we have a seperate class since sun doesn't allow us to extend StringBuffer for some reason and we want methods like replace over the whole buffer.
String| Constructor and Description |
|---|
StringObject()
Constructs an empty String buffer.
|
StringObject(int length)
Constructs an empty String buffer with the specified initial length.
|
StringObject(String str)
Constructs a String buffer with the specified initial value.
|
| Modifier and Type | Method and Description |
|---|---|
StringObject |
append(boolean b)
Appends a boolean to the end of this buffer.
|
StringObject |
append(char c)
Appends a character to the end of this buffer.
|
StringObject |
append(char[] str)
Appends an array of characters to the end of this buffer.
|
StringObject |
append(char[] str,
int offset,
int len)
Appends a part of an array of characters to the end of this buffer.
|
StringObject |
append(double d)
Appends a double to the end of this buffer.
|
StringObject |
append(float f)
Appends a float to the end of this buffer.
|
StringObject |
append(int i)
Appends an integer to the end of this buffer.
|
StringObject |
append(long l)
Appends a long to the end of this buffer.
|
StringObject |
append(Object obj)
Appends an object to the end of this buffer.
|
StringObject |
append(String str)
Appends a String to the end of this buffer.
|
int |
capacity()
Returns the current capacity of the String buffer.
|
char |
charAt(int index)
Returns the character at the specified index.
|
StringObject |
delete(int offset,
int len)
delete part of the buffer
|
void |
ensureCapacity(int minimumCapacity)
Ensures that the capacity of the buffer is at least equal to the
specified minimum.
|
byte[] |
getBytes() |
void |
getChars(int srcBegin,
int srcEnd,
char[] dst,
int dstBegin)
Copies the characters of the specified substring (determined by
srcBegin and srcEnd) into the character array, starting at the
array's dstBegin location.
|
(package private) char[] |
getValue() |
int |
indexOf(String str) |
int |
indexOf(String str,
int fromIndex) |
StringObject |
insert(int offset,
boolean b)
Inserts a boolean into the String buffer.
|
StringObject |
insert(int offset,
char c)
Inserts a character into the String buffer.
|
StringObject |
insert(int offset,
char[] str)
Inserts an array of characters into the String buffer.
|
StringObject |
insert(int offset,
double d)
Inserts a double into the String buffer.
|
StringObject |
insert(int offset,
float f)
Inserts a float into the String buffer.
|
StringObject |
insert(int offset,
int i)
Inserts an integer into the String buffer.
|
StringObject |
insert(int offset,
long l)
Inserts a long into the String buffer.
|
StringObject |
insert(int offset,
Object obj)
Inserts an object into the String buffer.
|
StringObject |
insert(int offset,
String str)
Inserts a String into the String buffer.
|
StringObject |
insertLinks(String oldstart,
String oldend,
String newstart,
String newend,
String startend)
inserts links
|
int |
length()
Returns the length (character count) of the buffer.
|
StringObject |
replace(int offset,
int len,
String str)
replace
|
StringObject |
replace(String oldstr,
String newstr)
replace
|
StringObject |
replace(String oldstart,
String oldend,
String newstart,
String newend)
Does a replace/insert.
|
StringObject |
replaceFirst(String oldstr,
String newstr)
replace
|
StringObject |
reverse()
Reverse the order of the characters in the String buffer.
|
void |
setCharAt(int index,
char ch)
Changes the character at the specified index to be ch.
|
void |
setLength(int newLength)
Sets the length of the String.
|
(package private) void |
setShared() |
String |
toString()
Converts to a String representing the data in the buffer.
|
public StringObject()
public StringObject(int length)
length - the initial lengthpublic StringObject(String str)
str - the initial value of the bufferpublic int length()
public int capacity()
public void ensureCapacity(int minimumCapacity)
minimumCapacity - the minimum desired capacitypublic void setLength(int newLength)
newLength - the new length of the bufferStringIndexOutOfBoundsException - If the length is invalid.public char charAt(int index)
index - the index of the desired characterStringIndexOutOfBoundsException - If the index is invalid.public void getChars(int srcBegin,
int srcEnd,
char[] dst,
int dstBegin)
srcBegin - begin copy at this offset in the StringsrcEnd - stop copying at this offset in the Stringdst - the array to copy the data intodstBegin - offset into dstStringIndexOutOfBoundsException - If there is an invalid index into the buffer.public void setCharAt(int index,
char ch)
index - the index of the characterch - the new characterStringIndexOutOfBoundsException - If the index is invalid.public StringObject append(Object obj)
obj - the object to be appendedpublic StringObject append(String str)
str - the String to be appendedpublic StringObject append(char[] str)
str - the characters to be appendedpublic StringObject append(char[] str, int offset, int len)
str - the characters to be appendedoffset - where to startlen - the number of characters to addpublic StringObject append(boolean b)
b - the boolean to be appendedpublic StringObject append(char c)
c - the character to be appendedpublic StringObject append(int i)
i - the integer to be appendedpublic StringObject append(long l)
l - the long to be appendedpublic StringObject append(float f)
f - the float to be appendedpublic StringObject append(double d)
d - the double to be appendedpublic StringObject insert(int offset, Object obj)
offset - the offset at which to insertobj - the object to insertStringIndexOutOfBoundsException - If the offset is invalid.public StringObject insert(int offset, String str)
offset - the offset at which to insertstr - the String to insertStringIndexOutOfBoundsException - If the offset is invalid.public StringObject insert(int offset, char[] str)
offset - the offset at which to insertstr - the characters to insertStringIndexOutOfBoundsException - If the offset is invalid.public StringObject insert(int offset, boolean b)
offset - the offset at which to insertb - the boolean to insertStringIndexOutOfBoundsException - If the offset is invalid.public StringObject insert(int offset, char c)
offset - the offset at which to insertc - the character to insertStringIndexOutOfBoundsException - If the offset invalid.public StringObject insert(int offset, int i)
offset - the offset at which to inserti - the integer to insertStringIndexOutOfBoundsException - If the offset is invalid.public StringObject insert(int offset, long l)
offset - the offset at which to insertl - the long to insertStringIndexOutOfBoundsException - If the offset is invalid.public StringObject insert(int offset, float f)
offset - the offset at which to insertf - the float to insertStringIndexOutOfBoundsException - If the offset is invalid.public StringObject insert(int offset, double d)
offset - the offset at which to insertd - the double to insertStringIndexOutOfBoundsException - If the offset is invalid.public StringObject reverse()
public String toString()
final void setShared()
final char[] getValue()
public StringObject delete(int offset, int len)
public StringObject replace(int offset, int len, String str)
public StringObject replaceFirst(String oldstr, String newstr)
public StringObject replace(String oldstr, String newstr)
public StringObject replace(String oldstart, String oldend, String newstart, String newend)
public StringObject insertLinks(String oldstart, String oldend, String newstart, String newend, String startend)
public int indexOf(String str)
public int indexOf(String str, int fromIndex)
public byte[] getBytes()
MMBase 1.9-SNAPSHOT - ${javadoctimestamp}