public class StringUtils
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String[] |
EMPTY_STRING_ARRAY |
static java.lang.String |
FALSE |
static java.lang.String |
TRUE |
| Constructor and Description |
|---|
StringUtils() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
asBoolean(java.lang.String value) |
static boolean |
asBoolean(java.lang.String value,
boolean defaultValue) |
static java.lang.Boolean |
asBooleanObject(java.lang.String value) |
static java.lang.Boolean |
asBooleanObject(java.lang.String value,
java.lang.Boolean defaultValue) |
static java.lang.Integer |
asInteger(java.lang.String value)
Returns the given value String as Integer.
|
static java.lang.Integer |
asInteger(java.lang.String value,
java.lang.Integer defaultValue)
Returns the given value String as Integer.
|
static java.lang.Long |
asLong(java.lang.String value)
Returns the given value String as Long.
|
static java.lang.Long |
asLong(java.lang.String value,
java.lang.Long defaultValue)
Returns the given value String as Long.
|
static java.lang.String |
decode(java.lang.String s)
Decode the given String to UTF-8.
|
static boolean |
isEmpty(java.lang.String str)
Checks if a String is empty ("") or null.
|
static boolean |
isNotEmpty(java.lang.String str)
Checks if a String is not empty ("") and not null.
|
static java.lang.String |
replaceAll(java.lang.String line,
java.lang.String oldString,
java.lang.String newString)
Replace the oldString by the newString in the line and returns the result.
|
static java.lang.String |
replaceEach(java.lang.String text,
java.lang.String[] searchList,
java.lang.String[] replacementList)
Replaces all occurrences of Strings within another String.
|
static java.lang.String |
xmlEscape(java.lang.String s)
Re-escape xml special characters
|
static java.lang.String |
xmlUnescape(java.lang.String s) |
public static final java.lang.String[] EMPTY_STRING_ARRAY
public static final java.lang.String TRUE
public static final java.lang.String FALSE
public static final java.lang.String replaceAll(java.lang.String line,
java.lang.String oldString,
java.lang.String newString)
line - the line to replace.oldString - old token to replace.newString - new token to replace.public static boolean isEmpty(java.lang.String str)
Checks if a String is empty ("") or null.
StringUtils.isEmpty(null) = true StringUtils.isEmpty("") = true
StringUtils.isEmpty(" ") = false StringUtils.isEmpty("bob") = false
StringUtils.isEmpty(" bob ") = false
str - the String to check, may be nulltrue if the String is empty or nullpublic static boolean isNotEmpty(java.lang.String str)
Checks if a String is not empty ("") and not null.
StringUtils.isNotEmpty(null) = false
StringUtils.isNotEmpty("") = false
StringUtils.isNotEmpty(" ") = true
StringUtils.isNotEmpty("bob") = true
StringUtils.isNotEmpty(" bob ") = true
str - the String to check, may be nulltrue if the String is not empty and not nullpublic static boolean asBoolean(java.lang.String value)
public static boolean asBoolean(java.lang.String value,
boolean defaultValue)
public static java.lang.Boolean asBooleanObject(java.lang.String value)
public static java.lang.Boolean asBooleanObject(java.lang.String value,
java.lang.Boolean defaultValue)
public static java.lang.Integer asInteger(java.lang.String value)
value - public static java.lang.Integer asInteger(java.lang.String value,
java.lang.Integer defaultValue)
value - defaultValue - public static java.lang.Long asLong(java.lang.String value)
value - public static java.lang.Long asLong(java.lang.String value,
java.lang.Long defaultValue)
value - defaultValue - public static java.lang.String replaceEach(java.lang.String text,
java.lang.String[] searchList,
java.lang.String[] replacementList)
Replaces all occurrences of Strings within another String.
A null reference passed to this method is a no-op, or if any "search string" or "string to replace"
is null, that replace will be ignored. This will not repeat. For repeating replaces, call the overloaded method.
StringUtils.replaceEach(null, *, *) = null
StringUtils.replaceEach("", *, *) = ""
StringUtils.replaceEach("aba", null, null) = "aba"
StringUtils.replaceEach("aba", new String[0], null) = "aba"
StringUtils.replaceEach("aba", null, new String[0]) = "aba"
StringUtils.replaceEach("aba", new String[]{"a"}, null) = "aba"
StringUtils.replaceEach("aba", new String[]{"a"}, new String[]{""}) = "b"
StringUtils.replaceEach("aba", new String[]{null}, new String[]{"a"}) = "aba"
StringUtils.replaceEach("abcde", new String[]{"ab", "d"}, new String[]{"w", "t"}) = "wcte"
(example of how it does not repeat)
StringUtils.replaceEach("abcde", new String[]{"ab", "d"}, new String[]{"d", "t"}) = "dcte"
text - text to search and replace in, no-op if nullsearchList - the Strings to search for, no-op if nullreplacementList - the Strings to replace them with, no-op if nullnull if null String inputjava.lang.IndexOutOfBoundsException - if the lengths of the arrays are not the same (null is ok, and/or size 0)public static java.lang.String decode(java.lang.String s)
content - public static java.lang.String xmlUnescape(java.lang.String s)
public static java.lang.String xmlEscape(java.lang.String s)
s - Copyright © 2019. All Rights Reserved.