Package com.google.inject.servlet
Class ServletUtils
- java.lang.Object
-
- com.google.inject.servlet.ServletUtils
-
final class ServletUtils extends java.lang.Object
Some servlet utility methods.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
ServletUtils.ByteAccumulator
Accumulates byte sequences while decoding strings, and encodes them into a StringBuilder.
-
Field Summary
Fields Modifier and Type Field Description private static com.google.common.base.Joiner
SLASH_JOINER
private static com.google.common.base.Splitter
SLASH_SPLITTER
-
Constructor Summary
Constructors Modifier Constructor Description private
ServletUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static java.lang.String
getContextRelativePath(javax.servlet.http.HttpServletRequest request)
Gets the context path relative path of the URI.private static java.lang.String
lenientDecode(java.lang.String string, java.nio.charset.Charset encoding, boolean decodePlus)
Percent-decodes a US-ASCII string into a Unicode string.(package private) static java.lang.String
normalizePath(java.lang.String path)
Normalizes a path by unescaping all safe, percent encoded characters.
-
-
-
Method Detail
-
getContextRelativePath
static java.lang.String getContextRelativePath(javax.servlet.http.HttpServletRequest request)
Gets the context path relative path of the URI. Returns the path of the resource relative to the context path for a request's URI, or null if no path can be extracted.Also performs url decoding and normalization of the path.
-
normalizePath
static java.lang.String normalizePath(java.lang.String path)
Normalizes a path by unescaping all safe, percent encoded characters.
-
lenientDecode
private static java.lang.String lenientDecode(java.lang.String string, java.nio.charset.Charset encoding, boolean decodePlus)
Percent-decodes a US-ASCII string into a Unicode string. The specified encoding is used to determine what characters are represented by any consecutive sequences of the form "%XX". This is the lenient kind of decoding that will simply ignore and copy as-is any "%XX" sequence that is invalid (for example, "%HH").- Parameters:
string
- a percent-encoded US-ASCII stringencoding
- a character encodingdecodePlus
- boolean to indicate whether to decode '+' as ' '- Returns:
- a Unicode string
-
-