| java.lang.Object org.mmbase.util.StringObject
StringObject | final public class StringObject (Code) | | 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.
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.
See Also: String author: Daniel Ockeloen author: Johannes Verelst (bugfix) author: Arthur van Hoff version: $Id: StringObject.java,v 1.11 2006/06/26 18:16:01 johannes Exp $ |
Constructor Summary | |
public | StringObject() Constructs an empty String buffer. | public | StringObject(int length) Constructs an empty String buffer with the specified initial length. | public | StringObject(String str) Constructs a String buffer with the specified initial value. |
Method Summary | |
public synchronized StringObject | append(Object obj) Appends an object to the end of this buffer. | public synchronized StringObject | append(String str) Appends a String to the end of this buffer. | public synchronized StringObject | append(char str) Appends an array of characters to the end of this buffer. | public synchronized StringObject | append(char str, int offset, int len) Appends a part of an array of characters to the end of this buffer. | public StringObject | append(boolean b) Appends a boolean to the end of this buffer. | public synchronized StringObject | append(char c) Appends a character to the end of this buffer. | public StringObject | append(int i) Appends an integer to the end of this buffer. | public StringObject | append(long l) Appends a long to the end of this buffer. | public StringObject | append(float f) Appends a float to the end of this buffer. | public StringObject | append(double d) Appends a double to the end of this buffer. | public int | capacity() Returns the current capacity of the String buffer. | public synchronized char | charAt(int index) Returns the character at the specified index. | public synchronized StringObject | delete(int offset, int len) | public synchronized void | ensureCapacity(int minimumCapacity) Ensures that the capacity of the buffer is at least equal to the
specified minimum. | public byte[] | getBytes() | public synchronized 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. | final char[] | getValue() | public int | indexOf(String str) | public int | indexOf(String str, int fromIndex) | public synchronized StringObject | insert(int offset, Object obj) Inserts an object into the String buffer. | public synchronized StringObject | insert(int offset, String str) Inserts a String into the String buffer. | public synchronized StringObject | insert(int offset, char str) Inserts an array of characters into the String buffer. | public StringObject | insert(int offset, boolean b) Inserts a boolean into the String buffer. | public synchronized StringObject | insert(int offset, char c) Inserts a character into the String buffer. | public StringObject | insert(int offset, int i) Inserts an integer into the String buffer. | public StringObject | insert(int offset, long l) Inserts a long into the String buffer. | public StringObject | insert(int offset, float f) Inserts a float into the String buffer. | public StringObject | insert(int offset, double d) Inserts a double into the String buffer. | public synchronized StringObject | insertLinks(String oldstart, String oldend, String newstart, String newend, String startend) | public int | length() Returns the length (character count) of the buffer. | public synchronized StringObject | replace(int offset, int len, String str) | public synchronized StringObject | replace(String oldstr, String newstr) | public synchronized StringObject | replace(String oldstart, String oldend, String newstart, String newend) Does a replace/insert. | public synchronized StringObject | replaceFirst(String oldstr, String newstr) | public synchronized StringObject | reverse() Reverse the order of the characters in the String buffer. | public synchronized void | setCharAt(int index, char ch) Changes the character at the specified index to be ch. | public synchronized void | setLength(int newLength) Sets the length of the String. | final void | setShared() | public String | toString() Converts to a String representing the data in the buffer. |
StringObject | public StringObject()(Code) | | Constructs an empty String buffer.
|
StringObject | public StringObject(int length)(Code) | | Constructs an empty String buffer with the specified initial length.
Parameters: length - the initial length |
StringObject | public StringObject(String str)(Code) | | Constructs a String buffer with the specified initial value.
Parameters: str - the initial value of the buffer |
append | public synchronized StringObject append(Object obj)(Code) | | Appends an object to the end of this buffer.
Parameters: obj - the object to be appended the StringBuffer itself, NOT a new one. |
append | public synchronized StringObject append(String str)(Code) | | Appends a String to the end of this buffer.
Parameters: str - the String to be appended the StringBuffer itself, NOT a new one. |
append | public synchronized StringObject append(char str)(Code) | | Appends an array of characters to the end of this buffer.
Parameters: str - the characters to be appended the StringBuffer itself, NOT a new one. |
append | public synchronized StringObject append(char str, int offset, int len)(Code) | | Appends a part of an array of characters to the end of this buffer.
Parameters: str - the characters to be appended Parameters: offset - where to start Parameters: len - the number of characters to add the StringBuffer itself, NOT a new one. |
append | public StringObject append(boolean b)(Code) | | Appends a boolean to the end of this buffer.
Parameters: b - the boolean to be appended the StringBuffer itself, NOT a new one. |
append | public synchronized StringObject append(char c)(Code) | | Appends a character to the end of this buffer.
Parameters: c - the character to be appended the StringBuffer itself, NOT a new one. |
append | public StringObject append(int i)(Code) | | Appends an integer to the end of this buffer.
Parameters: i - the integer to be appended the StringBuffer itself, NOT a new one. |
append | public StringObject append(long l)(Code) | | Appends a long to the end of this buffer.
Parameters: l - the long to be appended the StringBuffer itself, NOT a new one. |
append | public StringObject append(float f)(Code) | | Appends a float to the end of this buffer.
Parameters: f - the float to be appended the StringBuffer itself, NOT a new one. |
append | public StringObject append(double d)(Code) | | Appends a double to the end of this buffer.
Parameters: d - the double to be appended the StringBuffer itself, NOT a new one. |
capacity | public int capacity()(Code) | | 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.
|
charAt | public synchronized char charAt(int index)(Code) | | Returns the character at the specified index. An index ranges
from 0..length()-1.
Parameters: index - the index of the desired character exception: StringIndexOutOfBoundsException - If the index is invalid. |
delete | public synchronized StringObject delete(int offset, int len)(Code) | | delete part of the buffer
|
ensureCapacity | public synchronized void ensureCapacity(int minimumCapacity)(Code) | | Ensures that the capacity of the buffer is at least equal to the
specified minimum.
Parameters: minimumCapacity - the minimum desired capacity |
getBytes | public byte[] getBytes()(Code) | | |
getChars | public synchronized void getChars(int srcBegin, int srcEnd, char dst, int dstBegin)(Code) | | Copies the characters of the specified substring (determined by
srcBegin and srcEnd) into the character array, starting at the
array's dstBegin location. Both srcBegin and srcEnd must be legal
indexes into the buffer.
Parameters: srcBegin - begin copy at this offset in the String Parameters: srcEnd - stop copying at this offset in the String Parameters: dst - the array to copy the data into Parameters: dstBegin - offset into dst exception: StringIndexOutOfBoundsException - If there is an invalid index into the buffer. |
getValue | final char[] getValue()(Code) | | |
insert | public synchronized StringObject insert(int offset, Object obj)(Code) | | Inserts an object into the String buffer.
Parameters: offset - the offset at which to insert Parameters: obj - the object to insert the StringBuffer itself, NOT a new one. exception: StringIndexOutOfBoundsException - If the offset is invalid. |
insert | public synchronized StringObject insert(int offset, String str)(Code) | | Inserts a String into the String buffer.
Parameters: offset - the offset at which to insert Parameters: str - the String to insert the StringBuffer itself, NOT a new one. exception: StringIndexOutOfBoundsException - If the offset is invalid. |
insert | public synchronized StringObject insert(int offset, char str)(Code) | | Inserts an array of characters into the String buffer.
Parameters: offset - the offset at which to insert Parameters: str - the characters to insert the StringBuffer itself, NOT a new one. exception: StringIndexOutOfBoundsException - If the offset is invalid. |
insert | public StringObject insert(int offset, boolean b)(Code) | | Inserts a boolean into the String buffer.
Parameters: offset - the offset at which to insert Parameters: b - the boolean to insert the StringBuffer itself, NOT a new one. exception: StringIndexOutOfBoundsException - If the offset is invalid. |
insert | public synchronized StringObject insert(int offset, char c)(Code) | | Inserts a character into the String buffer.
Parameters: offset - the offset at which to insert Parameters: c - the character to insert the StringBuffer itself, NOT a new one. exception: StringIndexOutOfBoundsException - If the offset invalid. |
insert | public StringObject insert(int offset, int i)(Code) | | Inserts an integer into the String buffer.
Parameters: offset - the offset at which to insert Parameters: i - the integer to insert the StringBuffer itself, NOT a new one. exception: StringIndexOutOfBoundsException - If the offset is invalid. |
insert | public StringObject insert(int offset, long l)(Code) | | Inserts a long into the String buffer.
Parameters: offset - the offset at which to insert Parameters: l - the long to insert the StringBuffer itself, NOT a new one. exception: StringIndexOutOfBoundsException - If the offset is invalid. |
insert | public StringObject insert(int offset, float f)(Code) | | Inserts a float into the String buffer.
Parameters: offset - the offset at which to insert Parameters: f - the float to insert the StringBuffer itself, NOT a new one. exception: StringIndexOutOfBoundsException - If the offset is invalid. |
insert | public StringObject insert(int offset, double d)(Code) | | Inserts a double into the String buffer.
Parameters: offset - the offset at which to insert Parameters: d - the double to insert the StringBuffer itself, NOT a new one. exception: StringIndexOutOfBoundsException - If the offset is invalid. |
length | public int length()(Code) | | Returns the length (character count) of the buffer.
|
reverse | public synchronized StringObject reverse()(Code) | | Reverse the order of the characters in the String buffer.
|
setCharAt | public synchronized void setCharAt(int index, char ch)(Code) | | Changes the character at the specified index to be ch.
Parameters: index - the index of the character Parameters: ch - the new character exception: StringIndexOutOfBoundsException - If the index is invalid. |
setLength | public synchronized void setLength(int newLength)(Code) | | Sets the length of the String. If the length is reduced, characters
are lost. If the length is extended, the values of the new characters
are set to 0.
Parameters: newLength - the new length of the buffer exception: StringIndexOutOfBoundsException - If the length is invalid. |
setShared | final void setShared()(Code) | | |
toString | public String toString()(Code) | | Converts to a String representing the data in the buffer.
|
|
|