-
Notifications
You must be signed in to change notification settings - Fork 0
API StringBuffer
Mutable buffer for high-volume incremental string building.
StringBuffer is for building substantial text, typically inside a loop, without allocating an intermediate string per concatenation. Read the result with toString to keep the buffer usable, or with stringAndRelease to take the text and release the buffer deterministically.
Warning
Do not keep using an instance after release or stringAndRelease. The buffer resources are gone at that point.
| Member | Returns | Summary |
|---|---|---|
new StringBuffer([initialValue]) |
StringBuffer |
Creates a buffer, optionally seeded with text. |
buffer.append(...values) |
null |
Appends values. |
buffer.appendLine(...values) |
null |
Appends values followed by a line break. |
buffer.insert(index, value) |
null |
Inserts text at an index. |
buffer.clear() |
null |
Clears the buffer contents. |
buffer.toString() |
string |
Returns the current contents. |
buffer.release() |
null |
Releases the buffer resources. |
buffer.stringAndRelease() |
string |
Returns the contents, then releases the buffer. |
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
initialValue |
string |
No | Text the buffer starts with. |
Returns
StringBuffer — a new buffer.
Example
var buffer = new StringBuffer("Hello");
return buffer.toString(); // "Hello"Parameters
| Name | Type | Required | Description |
|---|---|---|---|
values |
any |
Yes | One or more values to append, passed as variadic arguments. |
Returns
null.
Behavior
Each value is converted to text and appended in order.
Example
var buffer = new StringBuffer();
buffer.append("A", 1);
return buffer.toString(); // "A1"Parameters
| Name | Type | Required | Description |
|---|---|---|---|
values |
any |
Yes | One or more values to append, passed as variadic arguments. |
Returns
null.
Behavior
Appends the values, then a line break.
Example
var buffer = new StringBuffer();
buffer.appendLine("first");
buffer.append("second");
return buffer.toString();Parameters
| Name | Type | Required | Description |
|---|---|---|---|
index |
number |
Yes | Position at which the text is inserted. |
value |
string |
Yes | Text to insert. |
Returns
null.
Example
var buffer = new StringBuffer("ac");
buffer.insert(1, "b");
return buffer.toString(); // "abc"Parameters
None.
Returns
null.
Behavior
Empties the contents but keeps the buffer usable, unlike release.
Example
var buffer = new StringBuffer("old");
buffer.clear();
return buffer.toString(); // ""Parameters
None.
Returns
string — the current contents.
Behavior
Does not release the buffer, so appending can continue afterwards.
Example
var buffer = new StringBuffer("value");
return buffer.toString(); // "value"Parameters
None.
Returns
null.
Behavior
Releases the internal resources. Call it when the accumulated text is no longer needed.
Example
var buffer = new StringBuffer("temporary");
buffer.release();
return 0;Parameters
None.
Returns
string — the current contents.
Behavior
Reads the text and releases the buffer in one step. This is the usual last call on a buffer.
Example
var buffer = new StringBuffer("done");
var text = buffer.stringAndRelease();
return text; // "done"AuroraScript.JIT 4.0.0 · Documentation Home · Repository · MIT License