public class StringUtilities extends Object
Constructor and Description |
---|
StringUtilities() |
Modifier and Type | Method and Description |
---|---|
static boolean |
contains(StringBuilder input,
char c)
Returns true if the character is contained in the provided StringBuilder.
|
static int |
getLevenshteinDistance(String s,
String t)
Calculate the Edit Distance between 2 Strings as a measure of similarity.
|
static boolean |
isEmpty(String str)
Returns true if String is empty ("") or null.
|
static boolean |
notNullOrEmpty(String str,
boolean trim)
Check to ensure that a
String is not null or empty (after optional
trimming of leading and trailing whitespace). |
static String |
replaceLinearWhiteSpace(String input) |
static String |
replaceNull(String test,
String replace)
Returns the replace value if the value of test is null, "null", or ""
|
static String |
stripControls(String input)
Removes all unprintable characters from a string
and replaces with a space.
|
static char[] |
union(char[]... list)
Union multiple character arrays.
|
public static String stripControls(String input)
input
- public static char[] union(char[]... list)
list
- the char[]s to unionpublic static boolean contains(StringBuilder input, char c)
input
- The inputc
- The character to check for to see if input
contains.public static String replaceNull(String test, String replace)
test
- The value to testreplace
- The replacement valuepublic static int getLevenshteinDistance(String s, String t)
s
- The source stringt
- The target Stringpublic static boolean notNullOrEmpty(String str, boolean trim)
String
is not null or empty (after optional
trimming of leading and trailing whitespace). Usually used with
assertions, as in
assert StringUtils.notNullOrEmpty(cipherXform, true) : "Cipher transformation may not be null or empty!";or an equivalent runtime check that throws an
IllegalArgumentException
.str
- The String
to be checked.trim
- If true
, the string is first trimmed before checking
to see if it is empty, otherwise it is not.public static boolean isEmpty(String str)
Copyright © 2022 The Open Web Application Security Project (OWASP). All rights reserved.