Class StringUtils


  • public class StringUtils
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String EMPTY_STRING  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private StringUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean hasPrefixMatch​(java.lang.String heyStack, java.lang.String... candidates)
      If a candidate is a prefix of the heyStack, then this is a match.
      static boolean isBlank​(java.lang.String str)
      Determines whether a given string is null, empty, or only contains whitespace.
      static java.util.List<java.lang.String> splitIntoMultipleLines​(java.lang.String s, int maxCharsPerLine)
      Method for splitting long strings into multiple lines.
      static java.lang.String substringBeforeLast​(java.lang.String s, java.lang.String separator)  
      static java.lang.String urlEncode​(java.lang.String s)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • StringUtils

        private StringUtils()
    • Method Detail

      • isBlank

        public static boolean isBlank​(java.lang.String str)

        Determines whether a given string is null, empty, or only contains whitespace. If it contains anything other than whitespace then the string is not considered to be blank and the method returns false.

        Parameters:
        str - The string to test.
        Returns:
        true if the string is null, or blank.
      • splitIntoMultipleLines

        public static java.util.List<java.lang.String> splitIntoMultipleLines​(java.lang.String s,
                                                                              int maxCharsPerLine)
        Method for splitting long strings into multiple lines. This is mainly used for pretty printing. Whitespace characters in the input string are not handled specially.

        All lines will have the length passed as maxCharsPerLine except the last one which may be shorter.

        If null is passed instead of a string then an empty list is returned. If zero or a negative maxCharsPerLine is passed then a list containing the input string as the only element is returned.

        Parameters:
        s - the string to be split into multiple lines
        maxCharsPerLine - the maximum characters a line may contain.
        Returns:
        a list of strings with the maximal length as specified.
      • hasPrefixMatch

        public static boolean hasPrefixMatch​(java.lang.String heyStack,
                                             java.lang.String... candidates)
        If a candidate is a prefix of the heyStack, then this is a match. If no candidates are specified, it matches any heyStack.
        Parameters:
        heyStack - the string to match candidates against
        candidates - the strings to test as possible prefixes
        Returns:
        true if the any of the candidates is a prefix match of the heystack or if there are no candidates.
      • substringBeforeLast

        public static java.lang.String substringBeforeLast​(java.lang.String s,
                                                           java.lang.String separator)
      • urlEncode

        public static java.lang.String urlEncode​(java.lang.String s)