Class ServletUtils

java.lang.Object
com.google.inject.servlet.ServletUtils

final class ServletUtils extends Object
Some servlet utility methods.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private static class 
    Accumulates byte sequences while decoding strings, and encodes them into a StringBuilder.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final com.google.common.base.Joiner
     
    private static final com.google.common.base.Splitter
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) static String
    getContextRelativePath(javax.servlet.http.HttpServletRequest request)
    Gets the context path relative path of the URI.
    private static String
    lenientDecode(String string, Charset encoding, boolean decodePlus)
    Percent-decodes a US-ASCII string into a Unicode string.
    (package private) static String
    Normalizes a path by unescaping all safe, percent encoded characters.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • SLASH_SPLITTER

      private static final com.google.common.base.Splitter SLASH_SPLITTER
    • SLASH_JOINER

      private static final com.google.common.base.Joiner SLASH_JOINER
  • Constructor Details

    • ServletUtils

      private ServletUtils()
  • Method Details

    • getContextRelativePath

      static 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 String normalizePath(String path)
      Normalizes a path by unescaping all safe, percent encoded characters.
    • lenientDecode

      private static String lenientDecode(String string, 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 string
      encoding - a character encoding
      decodePlus - boolean to indicate whether to decode '+' as ' '
      Returns:
      a Unicode string