Class StringUtils

java.lang.Object
net.adoptopenjdk.icedteaweb.StringUtils

public class StringUtils extends Object
  • Field Details

  • Constructor Details

    • StringUtils

      private StringUtils()
  • Method Details

    • isBlank

      public static boolean isBlank(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 List<String> splitIntoMultipleLines(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(String heyStack, 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 String substringBeforeLast(String s, String separator)
    • urlEncode

      public static String urlEncode(String s)