Class StrUtils


  • public class StrUtils
    extends Object
    • Field Detail

      • HEX_DIGITS

        public static final char[] HEX_DIGITS
    • Constructor Detail

      • StrUtils

        public StrUtils()
    • Method Detail

      • splitSmart

        public static List<String> splitSmart​(String s,
                                              char separator)
      • splitSmart

        public static List<String> splitSmart​(String s,
                                              char separator,
                                              boolean trimEmpty)
      • splitSmart

        public static void splitSmart​(String s,
                                      char separator,
                                      List<String> lst)
        Split a string based on a separator, but don't split if it's inside a string. Assume '\' escapes the next char both inside and outside strings.
      • splitSmart

        public static List<String> splitSmart​(String s,
                                              String separator,
                                              boolean decode)
        Splits a backslash escaped string on the separator.

        Current backslash escaping supported:
        \n \t \r \b \f are escaped the same as a Java String
        Other characters following a backslash are produced verbatim (\c => c)

        Parameters:
        s - the string to split
        separator - the separator to split on
        decode - decode backslash escaping
        Returns:
        not null
      • splitFileNames

        public static List<String> splitFileNames​(String fileNames)
        Splits file names separated by comma character. File names can contain comma characters escaped by backslash '\'
        Parameters:
        fileNames - the string containing file names
        Returns:
        a list of file names with the escaping backslashed removed
      • parseBoolean

        public static boolean parseBoolean​(CharSequence s)
        Return if a string starts with '1', 't', or 'T' and return false otherwise.
      • parseBool

        public static boolean parseBool​(String s)
        how to transform a String into a boolean... more flexible than Boolean.parseBoolean() to enable easier integration with html forms.
      • partialURLEncodeVal

        public static void partialURLEncodeVal​(StringBuilder dest,
                                               String val)
        URLEncodes a value, replacing only enough chars so that the URL may be unambiguously pasted back into a browser.

        Characters with a numeric value less than 32 are encoded. &,=,%,+,space are encoded.

      • appendEscapedTextToBuilder

        public static void appendEscapedTextToBuilder​(StringBuilder out,
                                                      String item,
                                                      char separator)
        writes chars from item to out, backslash escaping as needed based on separator -- but does not append the separator itself
      • isNullOrEmpty

        public static boolean isNullOrEmpty​(String string)
      • isNotNullOrEmpty

        public static boolean isNotNullOrEmpty​(String string)
      • isBlank

        public static boolean isBlank​(String string)
      • isNotBlank

        public static boolean isNotBlank​(String string)
      • equalsIgnoreCase

        public static boolean equalsIgnoreCase​(String left,
                                               String right)