StringBuilderSync
classin packageklyn
public class StringBuilderSync extends Object
└ StringBuilderSync

Thread-safe text builder.

This synchronized variant is intended for concurrent text assembly and produces standard Klyn String values.

It follows the same text model as String and StringBuilder:

  • UTF-16 text
  • size and length() count Unicode scalar values, not UTF-16 units
  • exact-length UTF-16 strings, including embedded U+0000
  • '\u0000' is ordinary embeddable text, not a terminator

Use it for shared textual logs, prompts or generated source fragments. It must not be used as a binary container.

Example
builder = StringBuilderSync()
builder.append("worker:")
builder.append(" 1")
print(builder.toString())
Properties
Modifier and Type Member Description
public readonly property isEmpty
isEmpty as Boolean
Returns true when no character is present.
public readonly property size
size as ULong
Returns the number of Unicode scalar values in the string builder.
Inherited Properties
propertyInherited Properties from Object: type
Constructors
Modifier and Type Member Description
public StringBuilderSync
StringBuilderSync(size as ULong = 256)
Creates a new synchronized builder.
public StringBuilderSync Creates a new synchronized builder initialized with text.
Methods
Modifier and Type Member Description
public append
append(char as CodeUnit) as StringBuilderSync
Appends one UTF-16 code unit to the builder.
public append
append(value as Boolean) as StringBuilderSync
Appends a boolean.
public append
append(value as Byte) as StringBuilderSync
Appends an unsigned byte.
public append
append(value as Char) as StringBuilderSync
Appends one Unicode scalar to the builder.
public append
append(value as Double) as StringBuilderSync
Appends a double.
public append
append(value as Float) as StringBuilderSync
Appends a float.
public append
append(value as Int) as StringBuilderSync
Appends a signed integer.
public append
append(value as Long) as StringBuilderSync
Appends a signed long.
public append
append(value as Object) as StringBuilderSync
Appends the string representation of an object.
public append
append(value as SByte) as StringBuilderSync
Appends a signed byte.
public append
append(value as Short) as StringBuilderSync
Appends a signed short.
public append
append(value as String) as StringBuilderSync
Appends a string.
public append
append(value as UInt) as StringBuilderSync
Appends an unsigned integer.
public append
append(value as ULong) as StringBuilderSync
Appends an unsigned long.
public append
append(value as UShort) as StringBuilderSync
Appends an unsigned short.
public clear Clears current content.
public insert
insert(position as Long, char as CodeUnit) as StringBuilderSync throws IndexException
Inserts one UTF-16 code unit.
public insert
insert(position as Long, value as Boolean) as StringBuilderSync throws IndexException
Inserts a boolean.
public insert
insert(position as Long, value as Byte) as StringBuilderSync throws IndexException
Inserts an unsigned byte.
public insert
insert(position as Long, value as Char) as StringBuilderSync throws IndexException
Inserts one Unicode scalar.
public insert
insert(position as Long, value as Double) as StringBuilderSync throws IndexException
Inserts a double.
public insert
insert(position as Long, value as Float) as StringBuilderSync throws IndexException
Inserts a float.
public insert
insert(position as Long, value as Int) as StringBuilderSync throws IndexException
Inserts a signed integer.
public insert
insert(position as Long, value as Long) as StringBuilderSync throws IndexException
Inserts a signed long.
public insert
insert(position as Long, value as Object) as StringBuilderSync throws IndexException
Inserts the string representation of an object.
public insert
insert(position as Long, value as SByte) as StringBuilderSync throws IndexException
Inserts a signed byte.
public insert
insert(position as Long, value as Short) as StringBuilderSync throws IndexException
Inserts a signed short.
public insert
insert(position as Long, value as String) as StringBuilderSync throws IndexException
Inserts a string at a given position.
public insert
insert(position as Long, value as UInt) as StringBuilderSync throws IndexException
Inserts an unsigned integer.
public insert
insert(position as Long, value as ULong) as StringBuilderSync throws IndexException
Inserts an unsigned long.
public insert
insert(position as Long, value as UShort) as StringBuilderSync throws IndexException
Inserts an unsigned short.
public length
length() as ULong
Returns current content length.
public remove
remove(position as Long, length as ULong) as StringBuilderSync throws IndexException
Removes a range of characters.
public reverse
reverse() as StringBuilderSync
Reverses characters in place.
public toCharArray
toCharArray() as Char[]
Returns the content as Unicode scalar values.
public toCodeUnitArray
toCodeUnitArray() as CodeUnit[]
Returns the content as UTF-16 code units.
public override toString
toString() as String
Returns a String representation of the builder content.
Inherited Methods
methodInherited Methods from Object: deepCopy, fromJson, hash, toDict, toJson, toMap, toString, toXml
Operators
Modifier and Type Member Description
public operator[](position as Long) as Char throws IndexException Gets or sets one Unicode scalar by index.