Package migratedb.v1.core.internal.util
Class StringUtils
- java.lang.Object
-
- migratedb.v1.core.internal.util.StringUtils
-
public final class StringUtils extends Object
-
-
Constructor Summary
Constructors Constructor Description StringUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanhasLength(String str)Checks whether this string is notnulland not empty.static booleanhasText(String s)Checks whether this string isn'tnulland contains at least one non-blank character.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.static List<String>tokenizeToStringCollection(String str, String delimiters)Splits this string into a collection using these delimiters.static StringtrimChar(String s, char c)static StringtrimOrPad(String str, int length)Trims or pads (with spaces) this string, so it has this exact length.static StringtrimOrPad(String str, int length, char padChar)Trims or pads this string, so it has this exact length.
-
-
-
Method Detail
-
trimOrPad
public static String trimOrPad(String str, int length)
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
public static String trimOrPad(String str, int length, char padChar)
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.
-
replaceAll
public static String replaceAll(String str, String originalToken, String replacementToken)
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
public static boolean hasLength(String str)
Checks whether this string is notnulland not empty.- Parameters:
str- The string to check.- Returns:
trueif it has content,falseif it isnullor blank.
-
hasText
public static boolean hasText(String s)
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
public static String[] tokenizeToStringArray(String str, String delimiters)
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
public static List<String> tokenizeToStringCollection(String str, String delimiters)
Splits this string into a collection using these delimiters.- Parameters:
str- The string to split.delimiters- The delimiters to use.- Returns:
- The resulting array.
-
startsAndEndsWith
public static boolean startsAndEndsWith(String str, String prefix, Collection<String> suffixes)
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.
-
-