|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectariba.util.core.FastStringBuffer
public class FastStringBuffer
Object subclass resembling the java.lang.StringBuffer class (an object that manages a mutable string). Unlike java.lang.StringBuffer, none of FastStringBuffer's methods are synchronized, which results in a significant performance increase. FastStringBuffer also has additional API that allows it to be more easily modified than the standard StringBuffer.
Constructor Summary | |
---|---|
FastStringBuffer()
Creates a FastStringBuffer containing the empty string. |
|
FastStringBuffer(char aChar)
Creates a FastStringBuffer containing the character aChar. |
|
FastStringBuffer(int length)
Constructs an empty String buffer with the specified initial length. |
|
FastStringBuffer(java.lang.String aString)
Creates a FastStringBuffer containing the characters in aString. |
|
FastStringBuffer(java.lang.String aString,
int start,
int end)
Creates a FastStringBuffer containing the characters in aString from the index start to end. |
Method Summary | |
---|---|
void |
append(char aChar)
Appends aChar to the FastStringBuffer. |
void |
append(char[] value)
Appends the char array to the FastStringBuffer. |
void |
append(FastStringBuffer aBuffer)
Appends a FastStringBuffer to this FastStringBuffer. |
void |
append(java.lang.Object aObject)
Appends a string representation of aObject to the FastStringBuffer. |
void |
append(java.lang.String aString)
Appends aString to the FastStringBuffer. |
void |
appendCharRange(char[] aChar,
int startOffset,
int endOffset)
Copies characters from the character array into the FastStringBuffer. |
void |
appendStringRange(java.lang.String aString,
int startOffset,
int endOffset)
Copies characters from the string into the FastStringBuffer. |
char[] |
charArray()
Returns the FastStringBuffer's char array, for situation where it is needed. |
char |
charAt(int index)
Returns the character at index. |
char[] |
getBuffer()
Return the buffer holding the state of this FormatBuffer. |
boolean |
getDoublesCapacityWhenGrowing()
Returns whether FastStringBuffer doubles its size when some data is inserted and the internal buffer is too small. |
int |
indexOf(char aChar)
Returns the index of the first occurrence of aChar in the FastStringBuffer. |
int |
indexOf(char aChar,
int offset)
Returns the index of the first occurrence of aChar in the FastStringBuffer, starting at character offset. |
int |
indexOf(java.lang.String value)
Returns the index of the first occurrence of value in the FastStringBuffer. |
int |
indexOf(java.lang.String value,
int offset)
Returns the index of the first occurrence of value in the FastStringBuffer, starting at character offset. |
void |
insert(char aChar,
int index)
Inserts aChar at index. |
void |
insert(java.lang.String aString,
int index)
Inserts aString at index. |
int |
length()
Returns the number of characters in the FastStringBuffer. |
void |
moveChars(int fromIndex,
int toIndex)
This removes the characters between fromIndex and toIndex (non inclusive.) if fromIndex <= toIndex the method does nothing. |
void |
removeCharAt(int index)
Removes the character at index. |
void |
replace(int index,
char[] value)
Replaces value at index. |
void |
replace(int index,
char value,
int span)
Replaces value at index for span chars. |
void |
replace(java.lang.String oldString,
java.lang.String newString)
For each instance of oldString found in the
buffer, we'll replace it with newString . |
void |
setCharAt(int index,
char ch)
Sets the character at the location index to the character ch. |
void |
setDoublesCapacityWhenGrowing(boolean aFlag)
Set whether the FastStringBuffer should double its size when some data is inserted and the internal buffer is too small. |
void |
setStringValue(java.lang.String aString)
Sets the FastStringBuffer's contents to the characters in aString. |
boolean |
startsWith(java.lang.String value)
Check if the FastStringBuffer's characters start with the contents of a specified String. |
boolean |
startsWith(java.lang.String value,
int offset)
Check if the FastStringBuffer's characters start with the contents of a specified String. |
java.lang.String |
substring(int startIndex,
int endIndex)
Returns the String for the FastStringBuffer's contents. |
boolean |
tabOrSpaceAt(int index)
Check if a tab or a space occurs at the specified position in the FastStringBuffer. |
java.lang.String |
toString()
Returns the String for the FastStringBuffer's contents. |
void |
truncateToLength(int aLength)
Truncates the FastStringBuffer to aLength characters. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public FastStringBuffer(int length)
length
- the initial length, must be greater than or
equal to zeropublic FastStringBuffer()
public FastStringBuffer(java.lang.String aString)
aString
- the initial string to holdpublic FastStringBuffer(java.lang.String aString, int start, int end)
aString
- the string to copy a range of characters fromstart
- the index of the string to start copying fromend
- the index of the string to end copying by, the
character at position end is excluded.public FastStringBuffer(char aChar)
aChar
- the initial character to containMethod Detail |
---|
public char[] getBuffer()
public void setDoublesCapacityWhenGrowing(boolean aFlag)
aFlag
- if true (the default value if the method is not
called) the array will double capacity when growing. If false
it will only pad by up to 20 characters.public boolean getDoublesCapacityWhenGrowing()
public void setStringValue(java.lang.String aString)
aString
- the string to set the contents of the
fastStringBuffer to. Any previous contents will be cleared.public java.lang.String substring(int startIndex, int endIndex)
startIndex
- the index of the FastStringBuffer to start
copying from.endIndex
- the index of the FastStringBuffer to end
copying with. The character at endIndex is excluded.
java.lang.StringIndexOutOfBoundsException
- if the
startIndex
or endIndex
arguments
index characters outside the bounds of the FastStringBuffer.public java.lang.String toString()
toString
in class java.lang.Object
public char charAt(int index)
index
- the index of the character to return.
java.lang.StringIndexOutOfBoundsException
- If the index is invalidpublic boolean startsWith(java.lang.String value)
value
- the String to match against
public boolean startsWith(java.lang.String value, int offset)
value
- the String to match against.offset
- the offset of FastStringBuffer's contents to
start the comparison at.
public int indexOf(java.lang.String value)
value
- the String to search for in the FastStringBuffer
-1
if the String does not occur.public int indexOf(java.lang.String value, int offset)
value
- the String to search for in the FastStringBufferoffset
- the offset into the FastStringBuffer's contents
to start searching at.
-1
if the String does not
occur or if the index is out of bounds.public int indexOf(char aChar, int offset)
aChar
- the character to locate in the FastStringBufferoffset
- the offset in the FastStringBuffer for the first
character to search
-1
if the char does not
occur.public int indexOf(char aChar)
indexOf(aChar, 0);
aChar
- the character to locate in the FastStringBuffer
-1
if the char does not occur.indexOf(java.lang.String)
public boolean tabOrSpaceAt(int index)
index
- the index of the FastStringBuffer's contents to check.
java.lang.StringIndexOutOfBoundsException
- If the index is invalid.public void setCharAt(int index, char ch)
index
- the index of the character in the
FastStringBuffer to replace. It must be >= 0 and <= the length.ch
- the character to replace the value with.
java.lang.StringIndexOutOfBoundsException
- If the index is invalid.public void append(char aChar)
aChar
- the character to append to the FastStringBufferpublic void append(java.lang.String aString)
aString
- the String to append to the FastStringBufferpublic void append(java.lang.Object aObject)
append(String.valueOf(aObject));
aObject
- the Object to append the String value of.public void append(char[] value)
value
- the character array to append to the stringpublic void append(FastStringBuffer aBuffer)
aBuffer
- the FastStringBuffer to append to this
FastStringBuffer.public void appendStringRange(java.lang.String aString, int startOffset, int endOffset)
The first character to be copied is at index startOffset
;
the last character to be copied is at index endOffset-1
(thus the total number of characters to be copied is
endOffset-startOffset
).
aString
- the source StringstartOffset
- index of the first character in the string
to copy.endOffset
- index after the last character in the string
to copy.
java.lang.StringIndexOutOfBoundsException
- If srcBegin or
srcEnd is out of range, or if srcBegin is greater than the
srcEnd.public void appendCharRange(char[] aChar, int startOffset, int endOffset)
The first character to be copied is at index startOffset
;
the last character to be copied is at index endOffset-1
(thus the total number of characters to be copied is
endOffset-startOffset
).
aChar
- the source character arraystartOffset
- index of the first character in the array
to copy.endOffset
- index after the last character in the array
to copy.
java.lang.StringIndexOutOfBoundsException
- If startOffset or
endOffset is out of range, or if startOffset is greater than the
endOffset.public void replace(int index, char[] value)
index
- the index in the FastStringBuffer to start
replacing characters at.value
- a character array used for the replacement
contents.
java.lang.StringIndexOutOfBoundsException
- if the index is invalid.public void replace(int index, char value, int span)
index
- index to start replacing atvalue
- character to replace withspan
- number of characters to replace
java.lang.StringIndexOutOfBoundsException
- if the index is
invalidpublic void replace(java.lang.String oldString, java.lang.String newString)
oldString
found in the
buffer, we'll replace it with newString
.
oldString
- string to replacenewString
- replacement stringpublic void insert(char aChar, int index)
aChar
- character to insertindex
- location to insert character at
java.lang.StringIndexOutOfBoundsException
- if the index is invalid.public void insert(java.lang.String aString, int index)
aString
- string to insert into the FastStringBufferindex
- location to insert string.
java.lang.StringIndexOutOfBoundsException
- If the index is invalid.public void removeCharAt(int index)
index
- location to remove the character from
java.lang.StringIndexOutOfBoundsException
- if the index is invalid.public void truncateToLength(int aLength)
aLength
- the length to truncate the FastStringBuffer topublic int length()
public void moveChars(int fromIndex, int toIndex)
fromIndex
- index to start removing characters fromtoIndex
- index to end removing characters
java.lang.StringIndexOutOfBoundsException
- if the fromIndex
and toIndex are outside the range of the string.public char[] charArray()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |