Package org.apache.maven.doxia.util
Class DoxiaStringUtils
- java.lang.Object
-
- org.apache.maven.doxia.util.DoxiaStringUtils
-
public class DoxiaStringUtils extends java.lang.ObjectUtility methods for string operations. This class provides methods that were previously supplied by Apache Commons Lang3.- Since:
- 2.1.0
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intcountMatches(java.lang.String str, java.lang.String sub)Counts how many times the substring appears in the larger string.static booleanisAllBlank(java.lang.String... strs)Checks if all strings are blank.static booleanisBlank(java.lang.String str)Checks if a string is blank (null, empty, or whitespace only).static booleanisNotEmpty(java.lang.String str)Checks if a string is not empty.static java.lang.StringremoveEnd(java.lang.String str, java.lang.String remove)Removes a substring only if it is at the end of a source string.static java.lang.Stringrepeat(java.lang.String str, int repeat)Repeats a string a certain number of times.static java.lang.Stringreplace(java.lang.String text, java.lang.String searchString, java.lang.String replacement)Replaces all occurrences of a string within another string.static java.lang.String[]split(java.lang.String str, java.lang.String separatorChars)Splits a string by specified delimiters.static java.lang.StringstripStart(java.lang.String str, java.lang.String stripChars)Strips any of a set of characters from the start of a string.
-
-
-
Method Detail
-
repeat
public static java.lang.String repeat(java.lang.String str, int repeat)Repeats a string a certain number of times.- Parameters:
str- the string to repeatrepeat- number of times to repeat- Returns:
- the repeated string
-
replace
public static java.lang.String replace(java.lang.String text, java.lang.String searchString, java.lang.String replacement)Replaces all occurrences of a string within another string.- Parameters:
text- the text to search and replace insearchString- the string to search forreplacement- the string to replace with- Returns:
- the text with any replacements processed
-
isNotEmpty
public static boolean isNotEmpty(java.lang.String str)
Checks if a string is not empty.- Parameters:
str- the string to check- Returns:
- true if the string is not null and not empty
-
isBlank
public static boolean isBlank(java.lang.String str)
Checks if a string is blank (null, empty, or whitespace only).- Parameters:
str- the string to check- Returns:
- true if the string is null, empty, or whitespace only
-
isAllBlank
public static boolean isAllBlank(java.lang.String... strs)
Checks if all strings are blank.- Parameters:
strs- the strings to check- Returns:
- true if all strings are blank
-
split
public static java.lang.String[] split(java.lang.String str, java.lang.String separatorChars)Splits a string by specified delimiters.- Parameters:
str- the string to splitseparatorChars- the characters to use as delimiters- Returns:
- an array of parsed strings, empty array if null string input
-
removeEnd
public static java.lang.String removeEnd(java.lang.String str, java.lang.String remove)Removes a substring only if it is at the end of a source string.- Parameters:
str- the source stringremove- the string to remove- Returns:
- the substring with the string removed if found
-
stripStart
public static java.lang.String stripStart(java.lang.String str, java.lang.String stripChars)Strips any of a set of characters from the start of a string.- Parameters:
str- the string to remove characters fromstripChars- the characters to remove- Returns:
- the stripped string
-
countMatches
public static int countMatches(java.lang.String str, java.lang.String sub)Counts how many times the substring appears in the larger string.- Parameters:
str- the string to checksub- the substring to count- Returns:
- the number of occurrences, 0 if either string is null
-
-