Package io.hawt.util

Class Strings


  • public class Strings
    extends Object
    String utility.
    • Constructor Detail

      • Strings

        public Strings()
    • Method Detail

      • trimString

        public static String trimString​(String value,
                                        int max)
      • isBlank

        public static boolean isBlank​(String text)
      • isNotBlank

        public static boolean isNotBlank​(String text)
      • sanitize

        public static String sanitize​(String name)
        Strip out any annoying to deal with characters from a string when used as a file or directory name
        Parameters:
        name -
        Returns:
      • sanitizeDirectory

        public static String sanitizeDirectory​(String name)
        Also remove any dots in the directory name
        Parameters:
        name -
        Returns:
      • cleanPath

        public static String cleanPath​(String path)
        Normalizes a path. If the path contains a single '/' character it is returned unchanged, otherwise the path is:
        1. stripped from all multiple consecutive occurrences of '/' characters
        2. stripped from trailing '/' character(s)
        Parameters:
        path - path to normalize
        Returns:
        normalized path
      • webContextPath

        public static String webContextPath​(String first,
                                            String... more)
        Creates a web context path from components. Concatenates all path components using '/' character as delimiter and the result is then:
        1. prefixed with '/' character
        2. stripped from all multiple consecutive occurrences of '/' characters
        3. stripped from trailing '/' character(s)
        Parameters:
        components - web context path components
        Returns:
        empty string or string which starts with a "/" character but does not end with a "/" character