MutableString
classin packageklyn
public final class MutableString
MutableString

Mutable Unicode text with reference identity. Ordinary string literals and toString() produce immutable String values; m"text" creates a MutableString. Assigning an alias preserves identity, and edits remain visible through it. A String snapshot remains unchanged by later edits, even through reflection. Size and indexing count Unicode scalars; codeUnits exposes a UTF-16 copy.

Example
text = m"Klyn"
snapshot = text.toString()
alias = text
text[0] = 'k'
assert alias == "klyn" and snapshot == "Klyn"
Properties
Modifier and Type Member Description
public readonly property codePoints
codePoints as Char[]
Independent array of Unicode scalar values.
public readonly property codeUnits
codeUnits as CodeUnit[]
Independent array of UTF-16 code units.
public readonly property isEmpty
isEmpty as Boolean
Whether the text is empty.
public readonly property size
size as ULong
Number of Unicode scalar values.
Constructors
Modifier and Type Member Description
public MutableString
MutableString(notnull value as Char[])
Creates mutable text using the String conversion rules.
public MutableString
MutableString(notnull value as CodeUnit[])
Creates mutable text using the String conversion rules.
public MutableString
MutableString(notnull value as MutableString)
Copies the value of another instance; later edits remain independent.
public MutableString
MutableString(notnull value as String = "")
Initializes editable text from an immutable String snapshot.
public MutableString Creates mutable text using the String conversion rules.
public MutableString Creates mutable text using the String conversion rules.
public MutableString Creates mutable text using the String conversion rules.
Methods
Modifier and Type Member Description
public static _slice
_slice(text as MutableString, start as Long, stop as Long, sliceStep as Long, hasStart as Boolean, hasStop as Boolean) as String
Implements scalar-based slicing while preserving omitted bounds.
public static _sliceAssign
_sliceAssign(text as String, start as Long, stop as Long, sliceStep as Long, hasStart as Boolean, hasStop as Boolean, replacement as String) as String
Internal helper used by the compiler to implement string slice assignment.
public capitalize
capitalize() as MutableString
Capitalizes the string in place (first character only).
public center
center(width as Long, fill as Char = ' ') as String
Returns immutable padded text, or the current snapshot if no padding is needed.
public count
count(notnull value as MutableString) as ULong
Queries text without changing it.
public count
count(notnull value as String) as ULong
Queries text without changing it.
public count
count(value as Char) as ULong
Counts a Unicode scalar in one forward traversal of an immutable snapshot.
public endsWith
endsWith(notnull value as MutableString) as Boolean
Queries text without changing it.
public endsWith
endsWith(notnull value as String) as Boolean
Queries text without changing it.
public endsWith
endsWith(notnull values as IList<MutableString>) as Boolean
Tests whether any supplied text matches.
public endsWith
endsWith(notnull values as IList<String>) as Boolean
Tests whether any supplied text matches.
public endsWith
endsWith(value as Char) as Boolean
Tests a scalar suffix without modifying this mutable text.
public equalsIgnoreCase
equalsIgnoreCase(notnull value as MutableString) as Boolean
Queries text without changing it.
public equalsIgnoreCase
equalsIgnoreCase(value as String) as Boolean
Queries text without changing it.
public static fromCodePoint
fromCodePoint(value as Int) as MutableString
Creates a Unicode scalar from its integer value and snapshots its text.
public override hash
hash() as Long
Returns a content hash, equal to the hash of equivalent String text.
public indexOf
indexOf(notnull value as MutableString, start as Long = 0) as Long
Queries text without changing it.
public indexOf
indexOf(notnull value as String, start as Long = 0) as Long
Queries text without changing it.
public indexOf
indexOf(value as Char, start as Long = 0) as Long
Finds the first occurrence of a Unicode scalar.
public isAlnum
isAlnum() as Boolean
Tests whether the non-empty text consists entirely of Unicode letters or digits.
public isAlpha
isAlpha() as Boolean
Tests whether the non-empty text consists entirely of Unicode letters.
public isBlank
isBlank() as Boolean
Tests whether the text is empty or consists entirely of whitespace.
public isDigit
isDigit() as Boolean
Tests whether the non-empty text consists entirely of Unicode digits.
public isLower
isLower() as Boolean
Tests whether all cased characters are lowercase, with at least one cased character.
public isSpace
isSpace() as Boolean
Tests whether the non-empty text consists entirely of Unicode whitespace.
public isUpper
isUpper() as Boolean
Tests whether all cased characters are uppercase, with at least one cased character.
public join
join(notnull values as IList<Char>) as String
Joins a read-only list without modifying its elements.
public join
join(notnull values as IList<CodeUnit>) as String
Joins UTF-16 code units without splitting supplementary characters.
public join
join(notnull values as IList<MutableString>) as String
Joins a read-only list without modifying its elements.
public join
join(notnull values as IList<String>) as String
Joins a read-only list without modifying its elements.
public lastIndexOf
lastIndexOf(notnull value as MutableString, start as Long = -1) as Long
Queries text without changing it.
public lastIndexOf
lastIndexOf(notnull value as String, start as Long = -1) as Long
Queries text without changing it.
public lastIndexOf
lastIndexOf(value as Char, start as Long = -1) as Long
Finds the last occurrence of a Unicode scalar.
public lines
lines() as ArrayList<String>
Splits CR, LF and CRLF lines without retaining line terminators.
public lower
lower() as MutableString
Converts the string to lowercase in place.
public lpad
lpad(width as Long, fill as Char = ' ') as String
Returns immutable padded text, or the current snapshot if no padding is needed.
public ltrim
ltrim() as MutableString
Removes leading whitespace in place.
public matches
matches(regex as RegEx) as Boolean
Tests the complete text against a regular expression.
public removeAccents
removeAccents() as MutableString
Removes accents in place.
public removeSGR
removeSGR() as String
Returns an immutable text transformation without modifying this instance.
public replace
replace(notnull oldValue as MutableString, notnull newValue as MutableString) as String
Returns an immutable String with substring replacements.
public replace
replace(notnull oldValue as String, newValue as Char) as String
Returns a replacement snapshot without modifying this mutable text.
public replace
replace(notnull oldValue as String, notnull newValue as String) as String
Returns an immutable String with substring replacements.
public replace
replace(oldValue as Char, newValue as Char) as String
Returns a replacement snapshot without modifying this mutable text.
public replace
replace(oldValue as Char, notnull newValue as String) as String
Returns a replacement snapshot without modifying this mutable text.
public replaceFirst
replaceFirst(notnull oldValue as MutableString, notnull newValue as MutableString) as String
Returns an immutable String with substring replacements.
public replaceFirst
replaceFirst(notnull oldValue as String, newValue as Char) as String
Returns a single-replacement snapshot without modifying this mutable text.
public replaceFirst
replaceFirst(notnull oldValue as String, notnull newValue as String) as String
Returns an immutable String with substring replacements.
public replaceFirst
replaceFirst(oldValue as Char, newValue as Char) as String
Returns a single-replacement snapshot without modifying this mutable text.
public replaceFirst
replaceFirst(oldValue as Char, notnull newValue as String) as String
Returns a single-replacement snapshot without modifying this mutable text.
public replaceLast
replaceLast(notnull oldValue as MutableString, notnull newValue as MutableString) as String
Returns an immutable String with substring replacements.
public replaceLast
replaceLast(notnull oldValue as String, newValue as Char) as String
Returns a single-replacement snapshot without modifying this mutable text.
public replaceLast
replaceLast(notnull oldValue as String, notnull newValue as String) as String
Returns an immutable String with substring replacements.
public replaceLast
replaceLast(oldValue as Char, newValue as Char) as String
Returns a single-replacement snapshot without modifying this mutable text.
public replaceLast
replaceLast(oldValue as Char, notnull newValue as String) as String
Returns a single-replacement snapshot without modifying this mutable text.
public rpad
rpad(width as Long, fill as Char = ' ') as String
Returns immutable padded text, or the current snapshot if no padding is needed.
public rtrim
rtrim() as MutableString
Removes trailing whitespace in place.
public split
split(delimiter as Char) as ArrayList<String>
Splits a snapshot at a Unicode scalar without modifying this mutable text.
public split
split(notnull delimiter as MutableString) as ArrayList<String>
Splits text into immutable String segments stored in a mutable list.
public split
split(notnull delimiter as String) as ArrayList<String>
Splits text into immutable String segments stored in a mutable list.
public startsWith
startsWith(notnull value as MutableString) as Boolean
Queries text without changing it.
public startsWith
startsWith(notnull value as String) as Boolean
Queries text without changing it.
public startsWith
startsWith(notnull values as IList<MutableString>) as Boolean
Tests whether any supplied text matches.
public startsWith
startsWith(notnull values as IList<String>) as Boolean
Tests whether any supplied text matches.
public startsWith
startsWith(value as Char) as Boolean
Tests a scalar prefix without modifying this mutable text.
public title
title() as MutableString
Capitalizes each word in place.
public toCapitalize
toCapitalize() as String
Returns an immutable text transformation without modifying this instance.
public toCharArray
toCharArray() as Char[]
Copies characters into an independently mutable array.
public toCodeUnitArray
toCodeUnitArray() as CodeUnit[]
Copies characters into an independently mutable array.
public toLower
toLower() as String
Returns an immutable text transformation without modifying this instance.
public toRemoveAccents
toRemoveAccents() as String
Returns an immutable text transformation without modifying this instance.
public override toString
toString() as String
Returns an immutable snapshot; subsequent edits do not change it.
public toTitle
toTitle() as String
Returns an immutable text transformation without modifying this instance.
public toTrim
toTrim() as String
Returns an immutable text transformation without modifying this instance.
public toUpper
toUpper() as String
Returns an immutable text transformation without modifying this instance.
public trim
trim() as MutableString
Removes leading and trailing whitespace in place.
public upper
upper() as MutableString
Converts the string to uppercase in place.
Operators
Modifier and Type Member Description
public operator in(notnull value as MutableString) as Boolean Tests substring membership.
public operator in(notnull value as String) as Boolean Tests substring membership.
public operator in(value as Char) as Boolean Tests scalar membership without converting integers or unrelated objects to text.
public static operator*(first as MutableString, count as ULong) as String Repeats mutable text.
public operator*=(count as ULong) as MutableString Repeats the content in place.
public static operator+(first as MutableString, second as MutableString) as String Concatenates mutable text.
public operator+=(notnull value as MutableString) as MutableString Appends another mutable value, including this instance itself.
public operator+=(value as Char) as MutableString Appends one Unicode scalar, not its quoted debug representation.
public operator+=(value as CodeUnit) as MutableString Appends one UTF-16 unit representing a BMP character.
public operator+=(value as String) as MutableString Appends text without changing the identity of this mutable instance.
public operator==(other as Object) as Boolean Compares textual content without converting unrelated objects.
public operator[](position as Long) as Char Returns the Unicode scalar at an index; negative indices count from the end.