Package migratedb.v1.core.internal.util
Class StringUtils
java.lang.Object
migratedb.v1.core.internal.util.StringUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringarrayToCommaDelimitedString(Object[] strings) Turns this string array in one comma-delimited string.static StringarrayToDelimitedString(String delimiter, Object[] strings) Turns this string array in one delimited string.static StringcollapseWhitespace(String str) Replaces all sequences of whitespace by a single blank.static StringcollectionToCommaDelimitedString(Collection<?> collection) Convenience method to return a Collection as a comma-delimited String. e.g. useful fortoString()implementations.static StringcollectionToDelimitedString(Collection<?> collection, String delimiter) Convenience method to return a Collection as a delimited String.static booleanChecks whether this string is notnulland not empty.static booleanChecks whether this string isn'tnulland contains at least one non-blank character.static booleanisCharAnyOf(char c, String chars) Checks whether this character matches any of these characters.static StringReturns the first n characters from this string, where n = count.static Stringstatic StringReplace all occurrences of a substring within a string with another string.static StringreplaceAll(String str, String originalToken, String replacementToken) Replaces all occurrences of this originalToken in this string with this replacementToken.static booleanstartsAndEndsWith(String str, String prefix, Collection<String> suffixes) Checks whetherstrboth begins with this prefix and ends withs either of these suffixes.static String[]tokenizeToStringArray(String str, String delimiters) Splits this string into an array using these delimiters.tokenizeToStringCollection(String str, char delimiterChar, char groupDelimiterChar) Splits this string into a collection using this delimiter and this group delimiter.tokenizeToStringCollection(String str, String delimiters) Splits this string into a collection using these delimiters.static Stringstatic StringtrimLeadingCharacter(String str, char character) Trim any leading occurrence of this character from the given String.static StringtrimOrLeftPad(String str, int length, char padChar) Trims or pads this string, so it has this exact length.static StringTrims or pads (with spaces) this string, so it has this exact length.static StringTrims or pads this string, so it has this exact length.static StringWrap this string at the word boundary at or below lineSize characters.static StringWrap this string every lineSize characters.
-
Constructor Details
-
StringUtils
public StringUtils()
-
-
Method Details
-
trimChar
-
trimOrPad
Trims or pads (with spaces) this string, so it has this exact length.- Parameters:
str- The string to adjust.nullis treated as an empty string.length- The exact length to reach.- Returns:
- The adjusted string.
-
trimOrPad
Trims or pads this string, so it has this exact length.- Parameters:
str- The string to adjust.nullis treated as an empty string.length- The exact length to reach.padChar- The padding character.- Returns:
- The adjusted string.
-
trimOrLeftPad
Trims or pads this string, so it has this exact length.- Parameters:
str- The string to adjust.nullis treated as an empty string.length- The exact length to reach.padChar- The padding character.- Returns:
- The adjusted string.
-
leftPad
-
collapseWhitespace
Replaces all sequences of whitespace by a single blank. Ex.: " "->" "- Parameters:
str- The string to analyse.- Returns:
- The input string, with all whitespace collapsed.
-
left
Returns the first n characters from this string, where n = count. If the string is shorter, the entire string will be returned. If the string is longer, it will be truncated.- Parameters:
str- The string to parse.count- The amount of characters to return.- Returns:
- The first n characters from this string, where n = count.
-
replaceAll
Replaces all occurrences of this originalToken in this string with this replacementToken.- Parameters:
str- The string to process.originalToken- The token to replace.replacementToken- The replacement.- Returns:
- The transformed str.
-
hasLength
Checks whether this string is notnulland not empty.- Parameters:
str- The string to check.- Returns:
trueif it has content,falseif it isnullor blank.
-
arrayToCommaDelimitedString
Turns this string array in one comma-delimited string.- Parameters:
strings- The array to process.- Returns:
- The new comma-delimited string. An empty string if
stringsis empty.nullif strings isnull.
-
arrayToDelimitedString
Turns this string array in one delimited string.- Parameters:
delimiter- The delimiter to use.strings- The array to process.- Returns:
- The new delimited string. An empty string if
stringsis empty.nullif strings isnull.
-
hasText
Checks whether this string isn'tnulland contains at least one non-blank character.- Parameters:
s- The string to check.- Returns:
trueif it has text,falseif not.
-
tokenizeToStringArray
Splits this string into an array using these delimiters.- Parameters:
str- The string to split.delimiters- The delimiters to use.- Returns:
- The resulting array.
-
tokenizeToStringCollection
Splits this string into a collection using these delimiters.- Parameters:
str- The string to split.delimiters- The delimiters to use.- Returns:
- The resulting array.
-
tokenizeToStringCollection
public static List<String> tokenizeToStringCollection(String str, char delimiterChar, char groupDelimiterChar) Splits this string into a collection using this delimiter and this group delimiter.- Parameters:
str- The string to split.delimiterChar- The delimiter to use.groupDelimiterChar- The character to use to delimit groups.- Returns:
- The resulting array.
-
replace
Replace all occurrences of a substring within a string with another string.- Parameters:
inString- String to examineoldPattern- String to replacenewPattern- String to insert- Returns:
- a String with the replacements
-
collectionToCommaDelimitedString
Convenience method to return a Collection as a comma-delimited String. e.g. useful fortoString()implementations.- Parameters:
collection- the Collection to analyse- Returns:
- The comma-delimited String.
-
collectionToDelimitedString
Convenience method to return a Collection as a delimited String. E.g. useful fortoString()implementations.- Parameters:
collection- the Collection to analysedelimiter- The delimiter.- Returns:
- The delimited String.
-
trimLeadingCharacter
Trim any leading occurrence of this character from the given String.- Parameters:
str- the String to check.character- The character to trim.- Returns:
- the trimmed String
- See Also:
-
startsAndEndsWith
Checks whetherstrboth begins with this prefix and ends withs either of these suffixes.- Parameters:
str- The string to check.prefix- The prefix.suffixes- The suffixes.- Returns:
trueif it does,falseif not.
-
wrap
Wrap this string every lineSize characters.- Parameters:
str- The string to wrap.lineSize- The maximum size of each line.- Returns:
- The wrapped string.
-
wordWrap
Wrap this string at the word boundary at or below lineSize characters.- Parameters:
str- The string to wrap.lineSize- The maximum size of each line.- Returns:
- The word-wrapped string.
-
isCharAnyOf
Checks whether this character matches any of these characters.- Parameters:
c- The char to check.chars- The chars that should match.- Returns:
trueif it does,false if not.
-