Libraries.Language.Support.TextBuilder Documentation

The TextBuilder class allows text to be built up into a buffer. It can be used to optimized a set of especially operations for appending text more quickly than through repeated concatenation. To use it, you can first create a TextBuilder. Then, optionally, set the max size of the buffer you would like. From there, you can append text values to the buffer and return the value with ToText.

Example Code

use Libraries.Language.Support.TextBuilder
use Libraries.System.File

//read some very large file into a buffer
File file
file:SetPath("Test.js")
text value = file:Read()
output "Size of file: " + value:GetSize()
TextBuilder builder
builder:SetMaxSize(51910886 * 2)
builder:Append(value)
output builder:GetMaxSize()
output builder:GetSize()

Inherits from: Libraries.Language.Object

Actions Documentation

Append(text value)

Add text to the buffer.

Parameters

  • text value: the text to add at the end of the buffer

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.

Parameters

Return

integer: The Compare result, Smaller, Equal, or Larger.

Example

Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)

Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

Parameters

Return

boolean: True if the hash codes are equal and false if they are not equal.

Example

use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)

GetHashCode()

This action gets the hash code for an object.

Return

integer: The integer hash code of the object.

Example

Object o
integer hash = o:GetHashCode()

GetMaxSize()

This action obtains the maximum size of the buffer. This buffer size matches or exceeds the amount of text currently in the buffer.

Return

integer: the size of the buffer.

GetSize()

This action gets the amount of text currently in the buffer.

Return

integer: the amount of text in the buffer.

SetMaxSize(integer size)

This action sets the maximum size of the buffer. This buffer size matches or exceeds the amount of text currently in the buffer.

Parameters

  • integer size: the size of the buffer.

ToText()

This action returns a text value from the buffer.

Return

text: the text