Package org.basex.util
Class Strings
java.lang.Object
org.basex.util.Strings
This class provides convenience operations for strings.
- Author:
- BaseX Team 2005-21, BSD License, Christian Gruen
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic StringConverts the given string to camel case.static Stringcapitalize(String string) Capitalizes the first letter of a string.static StringConverts the given string to a Java class name.static StringConcatenates multiple objects.static booleanChecks if a string contains a character.static StringDeletes a character from a string.static String[]Returns a string array with all supported encodings.static booleanChecks if a string ends with the specified character.static booleanCompares two strings for equality.static booleanCompares several strings for equality.static booleanCompares several strings for equality, ignoring the case.static StringReturns an MD5 hash in lower case.static booleanChecks if the specified string is "no", "false", "off" or "0".static StringnormEncoding(String encoding) Returns a unified representation of the specified encoding.static StringnormEncoding(String encoding, boolean utf16) Returns a unified representation of the specified encoding.static StringReturns an SHA256 hash in lower case.static String[]Splits a string around matches of the given separator.static String[]Splits a string around matches of the given separator.static booleanstartsWith(String string, char ch) Checks if a string starts with the specified character.static booleanChecks if the specified encoding is supported.static booleanChecks if the specified string is "yes", "true", "on" or "1".static intConverts the specified string into an integer value.static longConverts the specified string into an long value.static StringConverts a URI to a directory path.
-
Field Details
-
UTF8
UTF8 encoding string.- See Also:
-
UTF16
UTF16 encoding string.- See Also:
-
UTF16BE
UTF16BE encoding string.- See Also:
-
UTF16LE
UTF16 encoding string.- See Also:
-
UTF32
UTF16 encoding string.- See Also:
-
ISO88591
ISO-8859-1 encoding string.- See Also:
-
-
Method Details
-
toLong
Converts the specified string into an long value.Long.MIN_VALUEis returned if the input is invalid.- Parameters:
string- string to be converted- Returns:
- resulting long value
-
toInt
Converts the specified string into an integer value.Integer.MIN_VALUEis returned if the input is invalid.- Parameters:
string- string to be converted- Returns:
- resulting integer value
-
toBoolean
Checks if the specified string is "yes", "true", "on" or "1".- Parameters:
string- string to be checked- Returns:
- result of check
-
eq
Compares two strings for equality. The arguments may benull.- Parameters:
string1- first stringstring2- strings to be compared- Returns:
- true if one test is successful
-
eq
Compares several strings for equality. The arguments may benull.- Parameters:
string- first stringstrings- strings to be compared- Returns:
- true if one test is successful
-
eqic
Compares several strings for equality, ignoring the case.- Parameters:
string- first stringstrings- strings to be compared- Returns:
- true if one test is successful
-
split
Splits a string around matches of the given separator.- Parameters:
string- string to be splitseparator- separation character- Returns:
- resulting strings
-
split
Splits a string around matches of the given separator.- Parameters:
string- string to be splitseparator- separation characterlimit- maximum number of strings (ignored if-1)- Returns:
- resulting strings
-
delete
Deletes a character from a string.- Parameters:
string- stringch- character to be removed- Returns:
- resulting token
-
contains
Checks if a string contains a character.- Parameters:
string- stringch- character to search for- Returns:
- result of check
-
md5
Returns an MD5 hash in lower case.- Parameters:
string- string to be hashed- Returns:
- md5 hash
-
sha256
Returns an SHA256 hash in lower case.- Parameters:
string- string to be hashed- Returns:
- sha256 hash
-
normEncoding
Returns a unified representation of the specified encoding.- Parameters:
encoding- input encoding (UTF-8 is returned for anullreference)- Returns:
- encoding
-
normEncoding
Returns a unified representation of the specified encoding.- Parameters:
encoding- input encoding (UTF-8 is returned for anullreference)utf16- normalize UTF-16 encoding- Returns:
- encoding
-
supported
Checks if the specified encoding is supported.- Parameters:
encoding- encoding- Returns:
- result of check
-
capitalize
Capitalizes the first letter of a string.- Parameters:
string- input string- Returns:
- capitalized string
-
className
Converts the given string to a Java class name. Slashes will be replaced with dots, and the last package segment will be capitalized and camel-cased.- Parameters:
string- string to convert- Returns:
- class name
-
camelCase
Converts the given string to camel case.- Parameters:
string- string to convert- Returns:
- resulting string
-
no
Checks if the specified string is "no", "false", "off" or "0".- Parameters:
string- string to be checked- Returns:
- result of check
-
uri2path
Converts a URI to a directory path. See https://docs.basex.org/wiki/Repository#URI_Rewriting for details.- Parameters:
uri- namespace uri- Returns:
- converted path
-
startsWith
Checks if a string starts with the specified character.- Parameters:
string- stringch- character to be found- Returns:
- result of check
-
endsWith
Checks if a string ends with the specified character.- Parameters:
string- stringch- character to be found- Returns:
- result of check
-
concat
Concatenates multiple objects.- Parameters:
objects- objects- Returns:
- resulting string
-
encodings
Returns a string array with all supported encodings.- Returns:
- encodings
-