Interface STRING

All Known Implementing Classes:
STRINGImpl

public interface STRING
Provides implementations for standard string manipulation functions.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Convert a string to an integer.
    Replace all single quotes with two single quotes for escaping SQL insert statements.
    int
    indexof(String haystack, String needle)
    Gets the index of the first occurance of needle in haystack.
    itoa(int i)
    Convert an integer to a string.
    Return a literal double quote.
    replaceall(String s, String pattern, String replacement)
    Replace all occurances of pattern with one replacement quote for unescaping SQL insert statements.
    int
    Get the length of a string
    substr(String s, int begin, int end)
    Get a substring of an input string from begin (inclusive) to end (exclusive).
    Trim whitespace from the start and end of a string.
    Replace all occurances of two adjacent single quotes with one single quote for unescaping SQL insert statements.
  • Method Details

    • itoa

      String itoa(int i)
      Convert an integer to a string.
      Parameters:
      i - the integer to convert
      Returns:
      the string representation of the input integer
    • atoi

      int atoi(String s) throws XtumlException
      Convert a string to an integer.
      Parameters:
      s - the string to parse
      Returns:
      the integer representation of the input string
      Throws:
      XtumlException - if the string cannot be parsed to an integer.
    • substr

      String substr(String s, int begin, int end)
      Get a substring of an input string from begin (inclusive) to end (exclusive). If begin < 0, the result is a substring starting at the beginning of s. If begin > the length of s - 1, the result is an empty string. If end < 0 or > the length of s, the result is a substring starting at begin to the end of s. If end <= begin, the result is an empty string.
      Parameters:
      s - the input string
      begin - the start index of the substring (inclusive)
      end - the end index of the substring (exclusive)
      Returns:
      the substring of s from begin (inclusive) to end (exclusive)
    • strlen

      int strlen(String s)
      Get the length of a string
      Parameters:
      s - the input string
      Returns:
      the length of the input string
    • indexof

      int indexof(String haystack, String needle)
      Gets the index of the first occurance of needle in haystack. Returns -1 if needle is not contained in haystack.
      Parameters:
      haystack - the string to search
      needle - the string pattern to search for
      Returns:
      the index of the first occurance of needle in haystack
    • trim

      String trim(String s)
      Trim whitespace from the start and end of a string.
      Parameters:
      s - the input string
      Returns:
      the input string with all leading and trailing whitespace removed.
    • quote

      String quote()
      Return a literal double quote.
      Returns:
      a literal double quote
    • escapetics

      String escapetics(String s)
      Replace all single quotes with two single quotes for escaping SQL insert statements.
      Parameters:
      s - the input string
      Returns:
      the input string with all single quotes replaced with two single quotes
    • unescapetics

      String unescapetics(String s)
      Replace all occurances of two adjacent single quotes with one single quote for unescaping SQL insert statements.
      Parameters:
      s - the input string
      Returns:
      the input string with all occurances of two adjacent single quotes replaced with one single quote
    • replaceall

      String replaceall(String s, String pattern, String replacement)
      Replace all occurances of pattern with one replacement quote for unescaping SQL insert statements.
      Parameters:
      s - the input string
      replacement - the string to insert
      the - regex pattern string to find and replace
      Returns:
      the input string with all occurances of two adjacent single quotes replaced with one single quote