Class Util


  • public final class Util
    extends Object
    Utility methods originally defined in org.apache.catalina.util.RequestUtil and moved here in order to become accessible to code in web-naming and war-util.
    • Constructor Detail

      • Util

        public Util()
    • Method Detail

      • normalize

        public static String normalize​(String path,
                                       boolean replaceBackSlash)
        Normalize a relative URI path that may have relative values ("/./", "/../", and so on ) it it. WARNING - This method is useful only for normalizing application-generated paths. It does not try to perform security checks for malicious input.
        Parameters:
        path - Relative path to be normalized
        replaceBackSlash - Should '\\' be replaced with '/'
      • urlDecode

        public static String urlDecode​(String str)
        Decode and return the specified URL-encoded String. When the byte array is converted to a string, the system default character encoding is used... This may be different than some other servers.
        Parameters:
        str - The url-encoded string
        Throws:
        IllegalArgumentException - if a '%' character is not followed by a valid 2-digit hexadecimal number
      • urlDecode

        public static String urlDecode​(String str,
                                       String enc)
        Decode and return the specified URL-encoded String.
        Parameters:
        str - The url-encoded string
        enc - The encoding to use; if null, the default encoding is used
        Throws:
        IllegalArgumentException - if a '%' character is not followed by a valid 2-digit hexadecimal number
      • urlDecode

        public static String urlDecode​(byte[] bytes)
        Decode and return the specified URL-encoded byte array.
        Parameters:
        bytes - The url-encoded byte array
        Throws:
        IllegalArgumentException - if a '%' character is not followed by a valid 2-digit hexadecimal number
      • urlDecode

        public static String urlDecode​(byte[] bytes,
                                       String enc)
        Decode and return the specified URL-encoded byte array.
        Parameters:
        bytes - The url-encoded byte array
        enc - The encoding to use; if null, the default encoding is used
        Throws:
        IllegalArgumentException - if a '%' character is not followed by a valid 2-digit hexadecimal number
      • convertHexDigit

        public static byte convertHexDigit​(byte b)
        Convert a byte character value to hexidecimal digit value.
        Parameters:
        b - the character value byte