Sedona

sys::Str


sys::Obj
  sys::Str

public final class Str

Str encapsulates a byte array which stores a string of ASCII characters terminated by the null character. The characters must be less then 128 (the high bit must clear) for future UTF-8 support.


Str

public void Str(int bufLen)

The inline constructor for Str requires the max size of the character buffer including the space for the null terminator. For the following declaration declares a Str with enough memory to store 3 ASCII characters:

  inline Str(4) mystr
copyFromStr

public bool copyFromStr(Str from, int max)

Copy the specified string into this string's memory buffer. If the specified string contains more than max characters including the null terminator then return false and truncate the copy. Max should always be the size of this string's buffer.

equals

public bool equals(Str that)

Return if two strings contain the exact same characters.

equalsRegion

public bool equalsRegion(Str that, int start, int end)

Return if this entire string equals a region within the specified string. Start index is inclusive and end index is exclusive. The start index must be a valid index into the specified string's memory space, but the end index can be larger than the memory size.

fromBytes

public static native Str fromBytes(byte[] buf, int off)

Return a Str reference into the byte array at the specified offset. In the SVM we return a pointer to buf+off. In the JVM we return a new StrRef with the specified offset. No guarantee is made that the buffer contains the null terminator.

get

public int get(int index)

Get the character at the specified index.

index

public int index(int ch)

Return if the index of the specified character or -1 if not found in this string.

length

public int length()

Return number of characters in the string not including the null terminating character.

parseInt

public int parseInt()

Parse this string into an integer or return -1.

set

public void set(int index, int ch)

Set the character at the specified index.

startsWith

public bool startsWith(Str that)

Return if this string starts with the specified string.

suffix

public Str suffix(int newStart)

Perform an in-place trim on the string pointer by removing leading characters up to index 'newStart'. Note this method will return a different reference, the starting position of the new string, but the underlying memory does not change.

toBytes

public byte[] toBytes()

Get the backing byte array of this String.

trim

public Str trim()

Perform an in-place trim on the string pointer by removing any leading or trailing space characters. Note this method will change the characters in the string's buffer and will return a different reference the starting position of the new string.