Package org.apache.naming
Class Util
- java.lang.Object
-
- org.apache.naming.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 Summary
Constructors Constructor Description Util()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte
convertHexDigit(byte b)
Convert a byte character value to hexidecimal digit value.static String
normalize(String path, boolean replaceBackSlash)
Normalize a relative URI path that may have relative values ("/./", "/../", and so on ) it it.static String
urlDecode(byte[] bytes)
Decode and return the specified URL-encoded byte array.static String
urlDecode(byte[] bytes, String enc)
Decode and return the specified URL-encoded byte array.static String
urlDecode(String str)
Decode and return the specified URL-encoded String.static String
urlDecode(String str, String enc)
Decode and return the specified URL-encoded String.
-
-
-
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 normalizedreplaceBackSlash
- 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 stringenc
- 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 arrayenc
- 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
-
-