|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object | +--org.mmbase.util.StringObject
This Class is a growable buffer for characters. It is mainly used to create Strings. The compiler uses it to implement the "+" operator. For example:
"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.
String| Constructor Summary | |
StringObject()
Constructs an empty String buffer. |
|
StringObject(int length)
Constructs an empty String buffer with the specified initial length. |
|
StringObject(java.lang.String str)
Constructs a String buffer with the specified initial value. |
|
| Method Summary | |
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(java.lang.Object obj)
Appends an object to the end of this buffer. |
StringObject |
append(java.lang.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. |
int |
indexOf(java.lang.String str)
|
int |
indexOf(java.lang.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,
java.lang.Object obj)
Inserts an object into the String buffer. |
StringObject |
insert(int offset,
java.lang.String str)
Inserts a String into the String buffer. |
StringObject |
insertLinks(java.lang.String oldstart,
java.lang.String oldend,
java.lang.String newstart,
java.lang.String newend,
java.lang.String startend)
inserts links |
int |
length()
Returns the length (character count) of the buffer. |
StringObject |
replace(int offset,
int len,
java.lang.String str)
replace |
StringObject |
replace(java.lang.String oldstr,
java.lang.String newstr)
replace |
StringObject |
replace(java.lang.String oldstart,
java.lang.String oldend,
java.lang.String newstart,
java.lang.String newend)
replace, does a replace/insert. |
StringObject |
replaceFirst(java.lang.String oldstr,
java.lang.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. |
java.lang.String |
toString()
Converts to a String representing the data in the buffer. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public StringObject()
public StringObject(int length)
length - the initial lengthpublic StringObject(java.lang.String str)
str - the initial value of the buffer| Method Detail |
public 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(java.lang.Object obj)
obj - the object to be appendedpublic StringObject append(java.lang.String str)
str - the String to be appendedpublic StringObject append(char[] str)
str - the characters to be appended
public 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)
ch - 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 appended
public StringObject insert(int offset,
java.lang.Object obj)
offset - the offset at which to insertobj - the object to insertStringIndexOutOfBoundsException - If the offset is invalid.
public StringObject insert(int offset,
java.lang.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 insertch - 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 java.lang.String toString()
toString in class java.lang.Object
public StringObject delete(int offset,
int len)
public StringObject replace(int offset,
int len,
java.lang.String str)
public StringObject replaceFirst(java.lang.String oldstr,
java.lang.String newstr)
public StringObject replace(java.lang.String oldstr,
java.lang.String newstr)
public StringObject replace(java.lang.String oldstart,
java.lang.String oldend,
java.lang.String newstart,
java.lang.String newend)
public StringObject insertLinks(java.lang.String oldstart,
java.lang.String oldend,
java.lang.String newstart,
java.lang.String newend,
java.lang.String startend)
public int indexOf(java.lang.String str)
public int indexOf(java.lang.String str,
int fromIndex)
public byte[] getBytes()
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||