Plugins:StringBuffer
|
Exploring the StringBuffer Plugin
Overview
This CFC greatly increases the speed of string concatenation. CF strings are immutable. When you append a string to another string, a whole new string is created. This is fine for a small number of iterations but painfully slow and memory intensive for a large number of concatenation operations. This plugin switches between StringBuilder and StringBuffer if running under cf8
insertStr
Inserts the string into this string buffer at an offset.
Returns
- This function returns void
Arguments
| Key | Type | Required | Default | Description |
|---|---|---|---|---|
| offSet | numeric | No | 0 | the offset |
| inStr | string | Yes | --- | a string |
Examples
length
Returns the length (character count) of this string buffer.
Returns
- This function returns numeric
Examples
indexOf
Returns the index within this string of the first occurrence of the specified substring.
Returns
- This function returns numeric
Arguments
| Key | Type | Required | Default | Description |
|---|---|---|---|---|
| inStr | string | Yes | --- | the substring for which to search |
| fromPos | numeric | No | 0 | the index from which to start the search |
Examples
getString
Converts to a string representing the data in this string buffer.
Returns
- This function returns string
Examples
capacity
Returns the current capacity of the String buffer.
Returns
- This function returns numeric
Examples
reverseStr
The character sequence contained in this string buffer is replaced by the reverse of the sequence.
Returns
- This function returns void
Examples
delete
Removes the characters in a substring of this StringBuffer.
Returns
- This function returns void
Arguments
| Key | Type | Required | Default | Description |
|---|---|---|---|---|
| startPos | numeric | Yes | --- | The beginning index, inclusive. |
| endPos | numeric | Yes | --- | The ending index, exclusive. |
Examples
replaceStr
Replaces the chracters in a substring of this StringBuffer with characters in the specified inStr
Returns
- This function returns void
Arguments
| Key | Type | Required | Default | Description |
|---|---|---|---|---|
| startPos | numeric | Yes | --- | The beginning index, inclusive. |
| endPos | numeric | Yes | --- | The ending index, exclusive. |
| inStr | string | Yes | --- | a string |
Examples
getStringBuffer
Return the StringBuffer Java Object
Returns
- This function returns any
Examples
substring
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.
Returns
- This function returns string
Arguments
| Key | Type | Required | Default | Description |
|---|---|---|---|---|
| startPos | numeric | Yes | --- | The beginning index, inclusive. |
| endPos | numeric | No | [runtime expression] | The ending index, exclusive. |
Examples
append
Append a string to the buffer.
Returns
- This function returns void
Arguments
| Key | Type | Required | Default | Description |
|---|---|---|---|---|
| strIn | string | No | a string to append to the buffer |
Examples
lastIndexOf
Returns the index within this string of the last occurrence of the specified substring.
Returns
- This function returns numeric
Arguments
| Key | Type | Required | Default | Description |
|---|---|---|---|---|
| inStr | string | Yes | --- | the substring for which to search |
| fromPos | numeric | No | 0 | the index from which to start the search |
Examples
setLength
Sets the length of this String buffer.
Returns
- This function returns void
Arguments
| Key | Type | Required | Default | Description |
|---|---|---|---|---|
| newLength | numeric | Yes | --- | Length in characters to set. |
Examples
setup
initializes the StringBuffer CF/java object
Returns
- This function returns coldbox.system.Plugin
Arguments
| Key | Type | Required | Default | Description |
|---|---|---|---|---|
| strIn | string | No | A string to initialize the buffer with. The bufferLength will be the number of characters + 16. This argument is mutually exclusive to BufferLength | |
| BufferLength | numeric | No | 16 | The length to start the buffer at. The default is 16 characters. This argument is mutually exclusive to strIn |

SideBar
User Login 




Comments (