Package org.frankframework.util
Class StringUtil
java.lang.Object
org.frankframework.util.StringUtil
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic String
static String
concatStrings
(String part1, String separator, String part2) Concatenates two strings, if specified, uses the separator in between two strings.static int
countRegex
(String string, String regex) Counts the number of characters that the specified regexes will affect in the specified string.static String
static String
Hides the string based on the mode given.static String
static String
Hides the input string according to the given regex and mode.static String
hideAll
(String message, Collection<Pattern> collection) Hide all characters matching the given Regular Expression.static String
hideAll
(String message, Collection<Pattern> collection, int mode) Hide all characters matching the given Regular Expression.static String
Hides the input string according to the given regex and mode.static String
Turns the first Char into lower case.static String
reflectionToString
(Object object) toStrings and concatenates all fields of the given object, except fields containing the word 'password' or 'secret'.static String
safeCollectionToString
(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
(String input) Splits a string into a stream of substrings using default delimiter ",".splitToStream
(String input, String delim) Splits a string into a stream of substrings using specified delimiters.static String
Turns 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
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.Example:
String a = "We"; String b = "Frank"; String separator = "Are"; String res = StringUtil.concatStrings(a, separator, b); System.out.println(res); // prints "WeAreFrank"
- Parameters:
part1
- First stringseparator
- Specified separatorpart2
- Second string- Returns:
- the concatenated string
-
concat
-
hide
- Returns:
- hidden string with all characters replaced with '*'
- 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
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
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
- See Also:
-
hideAll
Hides the input string according to the given regex and mode. If mode is set to 1, then the first half of the string gets hidden. Else, all of it. -
hideAll
Hides the input string according to the given regex and mode. If mode is set to 1, then the first half of the string gets hidden. Else, all of it. -
countRegex
Counts the number of characters that the specified regexes will affect in the specified string.String s = "12ab34"; String regex = "\\d"; int regexCount = StringUtil.countRegex(s, regex); // regexCount gives out 4
-
lcFirst
Turns the first Char into lower case. -
ucFirst
Turns the first Char into upper case. -
safeCollectionToString
-
split
Splits a string into a list of substrings using default delimiter ",". Spaces before or after separators, and any leading trailing spaces, are trimmed from the result.- Parameters:
input
- the string to split, can be null.- Returns:
- a (modifiable)
List
of strings. An empty list if the input was null.
-
splitToStream
Splits a string into a stream of substrings using default delimiter ",". Spaces before or after separators, and any leading trailing spaces, are trimmed from the result.- Parameters:
input
- the string to split, can be null.- Returns:
- a
Stream
of strings. An empty stream if the input was null.
-
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)
List
of 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:
-