Class StringUtils
java.lang.Object
fr.opensagres.xdocreport.core.utils.StringUtils
String Utilities.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanstatic booleanstatic BooleanasBooleanObject(String value) static BooleanasBooleanObject(String value, Boolean defaultValue) static IntegerReturns the given value String as Integer.static IntegerReturns the given value String as Integer.static LongReturns the given value String as Long.static LongReturns the given value String as Long.static StringDecode the given String to UTF-8.static booleanChecks if a String is empty ("") or null.static booleanisNotEmpty(String str) Checks if a String is not empty ("") and not null.static final StringreplaceAll(String line, String oldString, String newString) Replace the oldString by the newString in the line and returns the result.static StringreplaceEach(String text, String[] searchList, String[] replacementList) Replaces all occurrences of Strings within another String.static StringRe-escape xml special charactersstatic String
-
Field Details
-
EMPTY_STRING_ARRAY
-
TRUE
- See Also:
-
FALSE
- See Also:
-
-
Constructor Details
-
StringUtils
public StringUtils()
-
-
Method Details
-
replaceAll
Replace the oldString by the newString in the line and returns the result.- Parameters:
line- the line to replace.oldString- old token to replace.newString- new token to replace.- Returns:
-
isEmpty
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- Parameters:
str- the String to check, may be null- Returns:
trueif the String is empty or null
-
isNotEmpty
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- Parameters:
str- the String to check, may be null- Returns:
trueif the String is not empty and not null
-
asBoolean
-
asBoolean
-
asBooleanObject
-
asBooleanObject
-
asInteger
Returns the given value String as Integer.- Parameters:
value-- Returns:
-
asInteger
Returns the given value String as Integer.- Parameters:
value-defaultValue-- Returns:
-
asLong
Returns the given value String as Long.- Parameters:
value-- Returns:
-
asLong
Returns the given value String as Long.- Parameters:
value-defaultValue-- Returns:
-
replaceEach
Replaces all occurrences of Strings within another String.
A
nullreference 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"- Parameters:
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 null- Returns:
- the text with any replacements processed,
nullif null String input - Throws:
IndexOutOfBoundsException- if the lengths of the arrays are not the same (null is ok, and/or size 0)- Since:
- 2.4
-
decode
Decode the given String to UTF-8.- Parameters:
content-- Returns:
-
xmlUnescape
-
xmlEscape
Re-escape xml special characters- Parameters:
s-- Returns:
-