public class StringUtils
extends java.lang.Object
| Constructor and Description |
|---|
StringUtils() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
escapeSql(java.lang.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 java.lang.String |
md5(java.lang.String message)
Generates the MD5 checksum for the specified message.
|
static java.lang.String |
md5(java.lang.String message,
int nchar)
Generates de MD5 checksum for the specified message.
|
static java.lang.String |
quotize(java.lang.String s)
Puts quotes around a String.
|
static java.lang.String |
quotize(java.lang.String s,
java.lang.String quoteChar)
Puts quotes around a String.
|
static java.lang.String |
readString(java.io.InputStream stream)
Reads a string from the input stream.
|
static java.lang.String |
singleQuotize(java.lang.String s)
Puts single quotes around a string.
|
public static java.lang.String quotize(java.lang.String s)
s - the string to be 'quotized'public static java.lang.String quotize(java.lang.String s,
java.lang.String quoteChar)
s - the string to be 'quotized'public static java.lang.String singleQuotize(java.lang.String s)
s - the string to be single 'quotized'public static java.lang.String md5(java.lang.String message)
message - The message.public static java.lang.String md5(java.lang.String message,
int nchar)
message - The message.nchar - The maximum number of chars for the result hash.public static java.lang.String readString(java.io.InputStream stream)
throws java.io.IOException
stream - The stream.java.io.IOException - If an I/O error occurs.public static java.lang.String escapeSql(java.lang.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 © 2018 Feedzai. All Rights Reserved.