Class DoxiaStringUtils


  • public class DoxiaStringUtils
    extends java.lang.Object
    Utility 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 int countMatches​(java.lang.String str, java.lang.String sub)
      Counts how many times the substring appears in the larger string.
      static boolean isAllBlank​(java.lang.String... strs)
      Checks if all strings are blank.
      static boolean isBlank​(java.lang.String str)
      Checks if a string is blank (null, empty, or whitespace only).
      static boolean isNotEmpty​(java.lang.String str)
      Checks if a string is not empty.
      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.
      static java.lang.String repeat​(java.lang.String str, int repeat)
      Repeats a string a certain number of times.
      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.
      static java.lang.String[] split​(java.lang.String str, java.lang.String separatorChars)
      Splits a string by specified delimiters.
      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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 repeat
        repeat - 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 in
        searchString - the string to search for
        replacement - 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 split
        separatorChars - 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 string
        remove - 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 from
        stripChars - 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 check
        sub - the substring to count
        Returns:
        the number of occurrences, 0 if either string is null