public class StringUtils extends Object
| Constructor and Description |
|---|
StringUtils() |
| Modifier and Type | Method and Description |
|---|---|
static String |
escapeSql(String str)
Apache Commons-Lang 2.X contained StringEscapeUtils#escapeSql, but this method was removed in 3.X as discussed
here: https://commons.apache.org/proper/commons-lang/article3_0.html#StringEscapeUtils.escapeSql
For this reason, the source code has been copied from 2.X to here so that we can continue to use the logic and
possibly build on it in the future.
|
static String |
md5(String message)
Generates the MD5 checksum for the specified message.
|
static String |
md5(String message,
int nchar)
Generates de MD5 checksum for the specified message.
|
static String |
quotize(String s)
Puts quotes around a String.
|
static String |
quotize(String s,
String quoteChar)
Puts quotes around a String.
|
static String |
readString(InputStream stream)
Reads a string from the input stream.
|
static String |
singleQuotize(String s)
Puts single quotes around a string.
|
public static String quotize(String s)
s - the string to be 'quotized'public static String quotize(String s, String quoteChar)
s - the string to be 'quotized'public static String singleQuotize(String s)
s - the string to be single 'quotized'public static String md5(String message)
message - The message.public static String md5(String message, int nchar)
message - The message.nchar - The maximum number of chars for the result hash.public static String readString(InputStream stream) throws IOException
stream - The stream.IOException - If an I/O error occurs.public static String escapeSql(String str)
Escapes the characters in a String to be suitable to pass to
an SQL query.
For example,
statement.executeQuery("SELECT * FROM MOVIES WHERE TITLE='" +
StringEscapeUtils.escapeSql("McHale's Navy") +
"'");
At present, this method only turns single-quotes into doubled single-quotes
("McHale's Navy" => "McHale''s Navy"). It does not
handle the cases of percent (%) or underscore (_) for use in LIKE clauses.
str - the string to escape, may be nullnull if null string inputCopyright © 2021 Feedzai. All rights reserved.