Class StringUtil
java.lang.Object
org.frankframework.util.StringUtil
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable StringConcatenate strings withseparator, skipping any arguments that may be null or"".static @Nullable StringconcatStrings(@Nullable String part1, String separator, @Nullable String part2) Concatenates two strings, if specified, uses the separator in between two strings.static intcountRegex(String string, String regex) Counts the number of characters that the specified regexes will affect in the specified string.static @Nullable StringHides all characters in the string, effectively returning a string the length of the original string but consisting entirely of} characters.invalid @value
{@value '*'static @Nullable StringHides the string based on the mode given.static @Nullable StringhideAll(@Nullable String message, @Nullable Collection<Pattern> collection) Hide all characters matching the given Regular Expression.static @Nullable StringhideAll(@Nullable String message, @Nullable Collection<Pattern> collection, int mode) Hide all characters matching the given Regular Expression.static StringHides the input string according to the given regex.static StringHides the input string according to the given regex and mode.static StringHides the input string according to the given regex and mode.static StringTurns the first Char into lower case.static StringreflectionToString(@Nullable Object object) toStrings and concatenates all fields of the given object, except fields containing the word 'password' or 'secret'.static StringsafeCollectionToString(@Nullable Collection<?> collection) Splits a string into a list of substrings using default delimiter ",".Splits a string into an array of substrings using specified delimiters.splitToStream(@Nullable String input) Splits a string into a stream of substrings using default delimiter ",".splitToStream(@Nullable String input, String delim) Splits a string into a stream of substrings using specified delimiters.static StringTurns the first Char into upper case.
-
Field Details
-
OMIT_PASSWORD_FIELDS_STYLE
public static final org.apache.commons.lang3.builder.ToStringStyle OMIT_PASSWORD_FIELDS_STYLE -
DEFAULT_STRING_SPLIT_DELIMITER
- See Also:
-
MATCH_OPTIONAL_WHITESPACE
- See Also:
-
-
Method Details
-
concatStrings
public static @Nullable String concatStrings(@Nullable String part1, String separator, @Nullable String part2) Concatenates two strings, if specified, uses the separator in between two strings. Does not use any separators if both or one of the strings are empty.Examples:
String a = "We"; String b = "Frank"; String separator = "Are"; String res1 = StringUtil.concatStrings(a, separator, b); System.out.println(res1); // prints "WeAreFrank" String c = null; String d = "Frank"; String res2 = StringUtil.concatStrings(c, separator, d); System.out.println(res2); // prints "Frank" String e = "We"; String f = ""; String re3 = StringUtil.concatStrings(c, separator, d); System.out.println(re3); // prints "We"- Parameters:
part1- First string, may be nullseparator- Specified separator, may not be nullpart2- Second string, may be NULL- Returns:
- the concatenated string, or NULL of both
part1andpart2were null.
-
concat
Concatenate strings withseparator, skipping any arguments that may be null or"". If all given parts to be concatenated are empty / null, then return null.- Parameters:
separator- Separator to put between partsparts- All parts to concatenate. May contain null values.- Returns:
- Concatenation of all parts with separator, or null.
-
hide
Hides all characters in the string, effectively returning a string the length of the original string but consisting entirely of} characters.invalid @value
{@value '*'- Returns:
- hidden string with all characters replaced with '*', or null if the input string was null.
- See Also:
-
hide
Hides the string based on the mode given. Mode 1 hides starting from the second character of the string until, excluding, the last character.Example:
String a = "test"; String res = StringUtil.hide(a, 1); System.out.println(res) // prints "t**t" -
hideAll
public static @Nullable String hideAll(@Nullable String message, @Nullable Collection<Pattern> collection) Hide all characters matching the given Regular Expression. If the set of expressions is null or empty it will return the raw message.- See Also:
-
hideAll
public static @Nullable String hideAll(@Nullable String message, @Nullable Collection<Pattern> collection, int mode) Hide all characters matching the given Regular Expression. If the set of expressions is null or empty it will return the raw message- See Also:
-
hideAll
-
hideAll
-
hideAll
-
countRegex
-
lcFirst
-
ucFirst
-
safeCollectionToString
-
split
-
splitToStream
-
split
Splits a string into an array of substrings using specified delimiters. Spaces before or after separators, and any leading trailing spaces, are trimmed from the result.- Parameters:
input- the string to split, can be null.delim- the delimiters to split the string by- Returns:
- a (modifiable)
Listof strings. An empty list if the input was null.
-
splitToStream
Splits a string into a stream of substrings using specified delimiters. Spaces before or after separators, and any leading trailing spaces, are trimmed from the result.- Parameters:
input- the string to split, can be null.delim- the delimiters to split the string by. Each character in the string is a potential delimiter, so if you want to split strings by for instance a space,,or;then pass" ,;".- Returns:
- a Stream of strings. An empty stream if the input was null.
-
reflectionToString
toStrings and concatenates all fields of the given object, except fields containing the word 'password' or 'secret'. 'fail-safe' method, returns toString if it is unable to use reflection. Uses theOMIT_PASSWORD_FIELDS_STYLE.- See Also:
-