8.70. File tom/String

class tom.String

inherits

State supers: Indexed, Comparable

instance tom.String

methods


deferred redeclare String
  frozen;

We'll return a String when frozen.


boolean
  dump_simple_p;

Return YES.


OutputStream
  dump_simple OutputStream s;

Print the receiving string, quoted.


deferred redeclare boolean
  equal String other;

Compare the receiving String with the other String.


deferred boolean
  equalByteString ByteString other;

Compare the receiving String with the other ByteString.


deferred boolean
  equalCharString CharString other;

Compare the receiving String with the other CharString.


deferred boolean
  equalUniqueString UniqueString other;

Compare the receiving String with the other UniqueString.


boolean
  equalModuloCase String other;

Compare the receiving String with the other String, ignoring case differences.


int
  compare id other;

Compare the receiving String with the other.


(int, int)
  rangeOfString String string
         range: (int, int) (start, len) = (0, -1);

Return the range of the occurrence of the string in the receiving string. Return a negative length in case it could not be found. The optional start and length can be specified to restrict the searching within the receiving string.


MutableArray
  componentsSeparatedBy char c
                 limit: int limit = -1
          excludeEmpty: boolean excl = NO
     substringSelector: selector sel = selector (String substring (int, int));

Return a (mutable) Array of strings, taken from the receiving string by splitting it at characters with the indicated char value. Thus, splitting `/usr/tmp' at each `/' returns an array holding the empty string, `usr', and `tmp'.

The optional argument limit specifies the maximum number of items in which the caller is interested, or -1 for all items. For example, if `/usr/foo/bar' is split on `/' in 3 items, the array returned contains `', `usr', and `foo/bar'.

The optional argument excl, if YES specifies that zero-length substrings are not to be included in the result. Thus, splitting `/aap/noot/mies/wim' in 3 items, ignoring empty items, returns an array containing `aap', `noot', and `mies/wim'.

The optional selector sel specifies the method to be called to extract the substrings from the receiving string. The default selector is "r_substring_(ii)". To retrieve mutable substrings, the selector "r_mutableSubstring_(ii)" could be used.


deferred MutableString
  mutableSubstring (int, int) (start, len)
pre
  start >= 0 && len >= -1;

Return a MutableString holding the characters from the receiving String in the (clipped) range (start, len).


deferred String
  substring (int, int) (start, len)
pre
  start >= 0 && len >= -1;

Return a constant String holding the characters from the receiving String in the (clipped) range (start, len).


deferred UniqueString
  uniqueString;

Return a unique version of the receiving string. Do not use this method to create unique strings; use [UniqueString with my_string] instead. (This method only creates strings which think they are unique; the UniqueString class ensures they actually are.)


id
  downcase;

Undocumented.


id
  upcase;

Undocumented.


double (value)
  doubleValue;

Return the double value at the start of the string.


(int, boolean, int) (value, full_range, actual_length)
    integerValue (int, int) (start, len)
    defaultBase: int base = 10
      allowSign: boolean signs = YES
    allowCBases: boolean c_bases = YES
  baseSeparator: byte base_separator = '_'
    decimalBase: boolean decimal_base = YES;

Convert the number contained in the receiving string from index start, running for len bytes (which -1 for unlimited length).

The value returned is a tuple (extracted value, occupied full range, actual length). If the actual length is 0, the extracted number will be 0.

The base defaults to 10, but can be any number. If it is larger than 10, alpha characters encountered have the value of 11 + the offset from the alpha character to the start of its range. Thus, `a' is 10, `z' is 35.

Iff signs, a leading `+' or `-' sign is accepted.

Iff c_bases, C-style base indicators may be used: a number starting with a `0' denotes an octal number; a number starting with `0x' or `0X' is a hexadecimal number.

Iff the base_separator is not 0, a number can be prefixed with a base indication followed by the base separator to specify the base of the actual number to follow. The base is read using the a decimal base, unless decimal_base is FALSE, in which case the base is read in the default base. Thus, `10_10', with `_' as a base separator, returns base if decimal_base is FALSE, and 10 if it was TRUE.


int
  intValue;

Simple front-end for integerValue (with default arguments).


int
  unsignedIntValue;

Simple front-end for integerValue, similar to intValue, but not allowing a negative value. For a negative value entered (due to integerValue not doing overflow checking), 0 is returned.


boolean
  isAlpha char c;

Return TRUE iff the character c denotes a letter.


boolean
  isDigit char c;

Return TRUE iff the character c is a digit.


boolean
  isLower char c;

Return TRUE iff the character c is in lower-case.


boolean
  isPunct char c;

Return TRUE iff the character c is a punctuation character.


boolean
  isSpace char c;

Return TRUE iff the character c is a space character.


boolean
  isUpper char c;

Return TRUE iff the character c is in upper-case.


char
  toLower char c;

Undocumented.


char
  toTitle char c;

Undocumented.


char
  toUpper char c;

Undocumented.


int
  digitValue char c;

Undocumented.


int
  alphaValue char c;

Undocumented.


id
  stringByDecoding String encoding_name;

Return a string by decoding it assuming it was encoded using the encoding named by encoding_name. The default implementation simply returns self.