shadow:standard

Class String

Parent class

shadow:standard@Object

Interfaces

shadow:standard@CanCompare<shadow:standard@String>, shadow:standard@CanIterate<code>, shadow:standard@CanIndex<int,ubyte>, shadow:standard@CanHash

immutable locked class String

Class String holds arbitrary-length sequences of UTF-8 code points stored in a fixed-size array of ubyte values. String objects are the most common way to represent text in Shadow. String objects differ from MutableString objects in that their contents cannot be changed.

See Also

Create Summary

Modifiers Return Types Method and Description
public () create()

Creates a new empty String object of length zero.

public () create(code[] data)

Creates a new String object whose contents are the code values contained in the given array.

public () create(String other)

Creates a new String which is a copy of the given String.

public () create(ubyte[] data)

Creates a new String object whose contents are the ubyte values contained in the given array.

Destroy Summary

Modifiers Return Types Method and Description
public () destroy()

Method Summary

Modifiers Return Types Method and Description
public readonly locked (int) compare(String other)

Compares the current object to another String, returning -1, 0, or 1, if the current object comes earlier, at exactly the same point, or later in a lexicographic ordering than the other value, respectively.

public readonly locked (String) concatenate(nullable Object other)

Produces a new String object whose contents are made up of the code points contained in the current object followed by those in the String representation of the other object.

public readonly locked (String) concatenate(String other)

Produces a new String object whose contents are made up of the code points contained in the current object followed by those in the other object.

public readonly (String) copy(AddressMap addresses)
public readonly locked (boolean) equal(String other)

Compares the current object to another String, returning true if they are identical.

public readonly locked (ubyte) index(long location)

Retrieves the ubyte value at the given offset inside the object.

public readonly locked (boolean) isEmpty()

Returns true if the String has length zero.

public readonly locked (Iterator<code>) iterator()

Gets iterator that can iterate over each code point in the String.

public readonly locked (String) substring(int start)

Produces a substring of this string representation, from the starting byte offset up to the end.

public readonly locked (String) substring(int start, int end)

Produces a substring of this string representation, from the starting byte offset up to but not including the ending byte offset.

public readonly locked (byte) toByte()

Parses the String object as a byte.

public readonly locked (double) toDouble()

Parses the String object as a double.

public readonly locked (float) toFloat()

Parses the String object as a float.

public readonly locked (int) toInt()

Parses the String object as an int.

public readonly locked (long) toLong()

Parses the String object as a long.

public readonly locked (String) toLowerCase()

Returns a lower-case version of this String.

public readonly locked (short) toShort()

Parses the String object as a short.

public readonly locked (String) toString()

Returns a String representation of this object, which is the object itself.

public readonly locked (ubyte) toUByte()

Parses the String object as a ubyte.

public readonly locked (uint) toUInt()

Parses the String object as a uint.

public readonly locked (ulong) toULong()

Parses the String object as a ulong.

public readonly locked (ushort) toUShort()

Parses the String object as a ushort.

public readonly locked (String) toUpperCase()

Returns an upper-case version of this String.

Property Summary

Modifiers Return Types Method and Description
public readonly get locked (immutable ubyte[]) chars()

Retrieves an immutable copy of the ubyte array inside the object.

public readonly get locked (code[]) codes()

Produces an array of code values corresponding to the UTF-8 code points stored in the object.

public readonly get locked (ulong) hash()

Finds a hash value for the current object.

public readonly get locked (int) size()

Gets the number of ubyte values stored in the object as an int.

public readonly get locked (long) sizeLong()

Gets the number of ubyte values stored in the object as a long.

Create Detail

create

public create() => ()

Creates a new empty String object of length zero.

create

public create(code[] data) => ()

Creates a new String object whose contents are the code values contained in the given array.

Parameters

data - array specifying the contents of the array

Throws

IllegalArgumentException - if the code values do not specify legal UTF-8 code points

create

public create(String other) => ()

Creates a new String which is a copy of the given String.

Parameters

other - String to copy

create

public create(ubyte[] data) => ()

Creates a new String object whose contents are the ubyte values contained in the given array.

Parameters

data - array specifying the contents of the array

Throws

IllegalArgumentException - if the ubyte values do not specify legal UTF-8 code points

Destroy Detail

destroy

public destroy() => ()

Method Detail

compare

public readonly locked compare(String other) => (int)

Compares the current object to another String, returning -1, 0, or 1, if the current object comes earlier, at exactly the same point, or later in a lexicographic ordering than the other value, respectively.

Parameters

other - value to compare to

Returns

whether earlier, identical, or later

concatenate

public readonly locked concatenate(nullable Object other) => (String)

Produces a new String object whose contents are made up of the code points contained in the current object followed by those in the String representation of the other object.

Parameters

other - object convert to String and then concatenate with this object

Returns

concatenated String

concatenate

public readonly locked concatenate(String other) => (String)

Produces a new String object whose contents are made up of the code points contained in the current object followed by those in the other object.

Parameters

other - String object to concatenate with this object

Returns

concatenated String

copy

public readonly copy(AddressMap addresses) => (String)

equal

public readonly locked equal(String other) => (boolean)

Compares the current object to another String, returning true if they are identical.

Parameters

other - object to compare to

Returns

true if identical

index

public readonly locked index(long location) => (ubyte)

Retrieves the ubyte value at the given offset inside the object.

Parameters

index - offset inside the object

Returns

ubyte value

Throws

IndexOutOfBoundsException - if the offset is illegal

isEmpty

public readonly locked isEmpty() => (boolean)

Returns true if the String has length zero.

Returns

true if the length is zero

iterator

public readonly locked iterator() => (Iterator<code>)

Gets iterator that can iterate over each code point in the String.

Returns

iterator

substring

public readonly locked substring(int start) => (String)

Produces a substring of this string representation, from the starting byte offset up to the end.

Parameters

start - starting offset

Returns

substring

substring

public readonly locked substring(int start, int end) => (String)

Produces a substring of this string representation, from the starting byte offset up to but not including the ending byte offset.

Parameters

start - starting offset

end - ending offset

Returns

substring

toByte

public readonly locked toByte() => (byte)

Parses the String object as a byte.

Returns

byte value

Throws

NumberFormatException - if the String representation is not a legal byte

toDouble

public readonly locked toDouble() => (double)

Parses the String object as a double.

Returns

double value

Throws

NumberFormatException - if the String representation is not a legal double

toFloat

public readonly locked toFloat() => (float)

Parses the String object as a float.

Returns

float value

Throws

NumberFormatException - if the String representation is not a legal float

toInt

public readonly locked toInt() => (int)

Parses the String object as an int.

Returns

int value

Throws

NumberFormatException - if the String representation is not a legal int

toLong

public readonly locked toLong() => (long)

Parses the String object as a long.

Returns

long value

Throws

NumberFormatException - if the String representation is not a legal long

toLowerCase

public readonly locked toLowerCase() => (String)

Returns a lower-case version of this String. Code points that are upper-case Latin letters are converted to lower-case versions in the returned String, and other code points are unaffected.

Returns

lower-case version

toShort

public readonly locked toShort() => (short)

Parses the String object as a short.

Returns

short value

Throws

NumberFormatException - if the String representation is not a legal short

toString

public readonly locked toString() => (String)

Returns a String representation of this object, which is the object itself.

Returns

String representation

toUByte

public readonly locked toUByte() => (ubyte)

Parses the String object as a ubyte.

Returns

ubyte value

Throws

NumberFormatException - if the String representation is not a legal ubyte

toUInt

public readonly locked toUInt() => (uint)

Parses the String object as a uint.

Returns

uint value

Throws

NumberFormatException - if the String representation is not a legal uint

toULong

public readonly locked toULong() => (ulong)

Parses the String object as a ulong.

Returns

ulong value

Throws

NumberFormatException - if the String representation is not a legal ulong

toUShort

public readonly locked toUShort() => (ushort)

Parses the String object as a ushort.

Returns

ushort value

Throws

NumberFormatException - if the String representation is not a legal ushort

toUpperCase

public readonly locked toUpperCase() => (String)

Returns an upper-case version of this String. Code points that are lower-case Latin letters are converted to upper-case versions in the returned String, and other code points are unaffected.

Returns

upper-case version

Property Detail

chars

public readonly get locked chars() => (immutable ubyte[])

Retrieves an immutable copy of the ubyte array inside the object.

Returns

byte array

codes

public readonly get locked codes() => (code[])

Produces an array of code values corresponding to the UTF-8 code points stored in the object.

Returns

code array

hash

public readonly get locked hash() => (ulong)

Finds a hash value for the current object.

Returns

hash value

size

public readonly get locked size() => (int)

Gets the number of ubyte values stored in the object as an int.

Returns

number of bytes

sizeLong

public readonly get locked sizeLong() => (long)

Gets the number of ubyte values stored in the object as a long.

Returns

number of bytes