Interface STRING
- All Known Implementing Classes:
STRINGImpl
public interface STRING
Provides implementations for standard string manipulation functions.
-
Method Summary
Modifier and TypeMethodDescriptionint
Convert a string to an integer.escapetics
(String s) Replace all single quotes with two single quotes for escaping SQL insert statements.int
Gets the index of the first occurance ofneedle
inhaystack
.itoa
(int i) Convert an integer to a string.quote()
Return a literal double quote.replaceall
(String s, String pattern, String replacement) Replace all occurances ofpattern
with onereplacement
quote for unescaping SQL insert statements.int
Get the length of a stringGet a substring of an input string frombegin
(inclusive) toend
(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
Convert an integer to a string.- Parameters:
i
- the integer to convert- Returns:
- the string representation of the input integer
-
atoi
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
Get a substring of an input string frombegin
(inclusive) toend
(exclusive). Ifbegin < 0
, the result is a substring starting at the beginning ofs
. Ifbegin >
the length ofs - 1
, the result is an empty string. Ifend < 0
or>
the length ofs
, the result is a substring starting atbegin
to the end ofs
. Ifend <= begin
, the result is an empty string.- Parameters:
s
- the input stringbegin
- the start index of the substring (inclusive)end
- the end index of the substring (exclusive)- Returns:
- the substring of
s
frombegin
(inclusive) toend
(exclusive)
-
strlen
Get the length of a string- Parameters:
s
- the input string- Returns:
- the length of the input string
-
indexof
Gets the index of the first occurance ofneedle
inhaystack
. Returns -1 ifneedle
is not contained inhaystack
.- Parameters:
haystack
- the string to searchneedle
- the string pattern to search for- Returns:
- the index of the first occurance of
needle
inhaystack
-
trim
-
quote
-
escapetics
-
unescapetics
-
replaceall
Replace all occurances ofpattern
with onereplacement
quote for unescaping SQL insert statements.- Parameters:
s
- the input stringreplacement
- the string to insertthe
- regex pattern string to find and replace- Returns:
- the input string with all occurances of two adjacent single quotes replaced with one single quote
-