Package org.citrusframework.util
Class StringUtils
java.lang.Object
org.citrusframework.util.StringUtils
Utility helper class for Strings.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic StringappendSegmentToUrlPath(String path, String segment) Appends a URL segment to an existing URL path.static StringConverts the first letter of the given input string to lowercase while leaving the rest of the string unchanged.static StringConverts the first letter of the given input string to uppercase while leaving the rest of the string unchanged.static booleanHelper method checks for null or blank String.static booleanHelper method checks for non-null and non-blank String.static booleanString helper checking for isEmpty String and adds null check on given parameter.static booleanisNotEmpty(String str) String helper checking for isEmpty String and adds null check on given parameter.static StringnormalizeWhitespace(String text, boolean normalizeWhitespace, boolean normalizeLineEndingsToUnix) Normalizes the given text by replacing all whitespace characters (identified by {@link Character#isWhitespace) by a single space and replacing windows style line endings with unix style line endings.static Stringstatic voidtrimTrailingComma(StringBuilder builder) Trims trailing whitespace characters and the first trailing comma from the end of the given StringBuilder.
-
Field Details
-
URL_PATH_SEPARATOR
- See Also:
-
-
Method Details
-
hasText
Helper method checks for non-null and non-blank String. -
hasNoText
Helper method checks for null or blank String. -
isEmpty
String helper checking for isEmpty String and adds null check on given parameter. -
isNotEmpty
String helper checking for isEmpty String and adds null check on given parameter. -
appendSegmentToUrlPath
Appends a URL segment to an existing URL path.This method ensures that the provided segment is appended correctly to the base path, handling cases where there may or may not be existing separators (`/`). It avoids duplicate separators and ensures proper formatting of the resulting URL.
- Parameters:
path- the base URL path to which the segment will be appended. Ifnull, the segment will be returned.segment- the segment to append to the base path. Ifnull, the original path will be returned.- Returns:
- the combined URL path with the appended segment, properly formatted.
-
quote
-
trimTrailingComma
Trims trailing whitespace characters and the first trailing comma from the end of the given StringBuilder.This method removes all trailing whitespace characters (such as spaces, tabs, and newline characters) and the first trailing comma found from the end of the content in the provided StringBuilder. Any additional commas or whitespace characters after the first trailing comma are not removed.
- Parameters:
builder- the StringBuilder whose trailing whitespace characters and first comma are to be removed
-
convertFirstCharToUpperCase
Converts the first letter of the given input string to uppercase while leaving the rest of the string unchanged. If the input string is empty or null, an empty string is returned.- Parameters:
input- The string to be converted. It can be null or empty.- Returns:
- the string in with upper case first letter
-
convertFirstCharToLowerCase
Converts the first letter of the given input string to lowercase while leaving the rest of the string unchanged. If the input string is empty or null, an empty string is returned.- Parameters:
input- The string to be converted. It can be null or empty.- Returns:
- the string in with upper case first letter
-
normalizeWhitespace
public static String normalizeWhitespace(String text, boolean normalizeWhitespace, boolean normalizeLineEndingsToUnix) Normalizes the given text by replacing all whitespace characters (identified by {@link Character#isWhitespace) by a single space and replacing windows style line endings with unix style line endings.
-