public final class StringUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static boolean |
compareCaseInsensitiveString(String s1,
String s2)
Compares two strings in a case insensitive manner, that also allows for
either of the strings to be null, without issue.
|
static boolean |
contains(String s1,
String s2)
Check if one string contains another string.
|
static boolean |
containsCaseInsensitive(String s1,
String s2)
Check if one string contains another string in a case insensitive manner.
|
static String |
encodeURIComponent(String component,
String encoding)
Encodes the passed String using an algorithm that's compatible
with JavaScript's
encodeURIComponent function. |
static List<String> |
getParameter(String list,
String delimiter,
String parameterName)
Takes a list as a String (where each element is of the form name=value) and returns the value
specified by parameterName (if it exists).
|
static String |
ifNullOrEmpty(String original,
String defaultString)
Checks that the original string is not null nor empty, if so it returns the non-null default string instead.
|
static String |
insertContent(String original,
int position,
String content)
Inserted content into a string.
|
static boolean |
isAnyBlank(Set<String> xs)
Tests whether any string in the given set is blank.
|
static boolean |
isBlank(String s)
Determines if the string is blank.
|
static boolean |
isEmpty(String s)
Determines if the string is empty.
|
static boolean |
isEqualTo(String s1,
String s2)
Compare two strings for equality.
|
static boolean |
isNotBlank(String s)
Determines if the string is not blank.
|
static boolean |
isNotEmpty(String s)
Determines if the string is not empty.
|
static boolean |
match(String value,
String strPattern)
Match the value to the regular expression pattern.
|
static List<String> |
split(String content,
Pattern pattern)
Splits a string into a list of elements by a pattern.
|
static boolean |
startsWith(String s1,
String s2)
Check if one string starts with another string.
|
static String |
tagSwap(String content,
Map<String,String> tagSwapMap)
Swaps content with tags with the provided tag values.
|
public static String tagSwap(String content, Map<String,String> tagSwapMap)
content - The String content to be replacedtagSwapMap - A map containing the replacable tokens with their new valuespublic static String insertContent(String original, int position, String content)
original - The original string.position - The insertion position.content - The content to insert.public static List<String> getParameter(String list, String delimiter, String parameterName)
list - The list e.g. a=1,b=2,c=5delimiter - The delimiter used to separate the elements (e.g. ",")parameterName - The name of the parameter to returnpublic static String ifNullOrEmpty(String original, String defaultString)
original - the original stringdefaultString - the non-null default stringpublic static String encodeURIComponent(String component, String encoding) throws UnsupportedEncodingException
encodeURIComponent function. Returns
null if the String is null.component - String to be encoded.encoding - The name of character encoding.UnsupportedEncodingException - If the named encoding is not supportedpublic static boolean isEmpty(String s)
s - string to testpublic static boolean isBlank(String s)
s - string to testpublic static boolean isNotEmpty(String s)
s - string to testpublic static boolean isNotBlank(String s)
s - string to testpublic static boolean isAnyBlank(Set<String> xs)
xs - the set of strings.true if the set is null or empty or if any member of the set is blank.isBlank(String)public static boolean isEqualTo(String s1, String s2)
s1 - first string to compare.s2 - second string to compare.public static boolean compareCaseInsensitiveString(String s1, String s2)
s1 - the first string to be compared.s2 - the second string to tbe compared.public static boolean contains(String s1, String s2)
s1 - The string to check in.s2 - The string to check for.public static boolean containsCaseInsensitive(String s1, String s2)
s1 - The string to check in.s2 - The string to check for.public static boolean startsWith(String s1, String s2)
s1 - The string to check in.s2 - The string to check for.public static boolean match(String value, String strPattern)
value - The value to match on.strPattern - The pattern to match.public static List<String> split(String content, Pattern pattern)
content - the content to split into a list of elements.pattern - the regular expression to use to split elements.Copyright © 2010–2023 Open Identity Platform Community. All rights reserved.