Class ContainerUtils


  • public class ContainerUtils
    extends java.lang.Object
    Utility methods used by container implementations.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.lang.String[] REPLACEMENTS  
      private static java.lang.String[] TOKENS  
    • Constructor Summary

      Constructors 
      Constructor Description
      ContainerUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String encodeUnsafeCharacters​(java.lang.String originalQueryString)
      Encodes (predefined subset of) unsafe/unwise URI characters with the percent-encoding.
      static java.lang.String getHandlerPath​(java.lang.String uri)
      Splits URI address from query params and returns it.
      static java.lang.String reduceLeadingSlashes​(java.lang.String path)
      Reduces the number of slashes before the path to only one slash.
      • Methods inherited from class java.lang.Object

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

      • TOKENS

        private static final java.lang.String[] TOKENS
      • REPLACEMENTS

        private static final java.lang.String[] REPLACEMENTS
    • Constructor Detail

      • ContainerUtils

        public ContainerUtils()
    • Method Detail

      • encodeUnsafeCharacters

        public static java.lang.String encodeUnsafeCharacters​(java.lang.String originalQueryString)
        Encodes (predefined subset of) unsafe/unwise URI characters with the percent-encoding.

        Replaces the predefined set of unsafe URI characters in the query string with its percent-encoded counterparts. The reserved characters (as defined by the RFC) are automatically encoded by browsers, but some characters are in the "gray zone" - are not explicitly forbidden, but not recommended and known to cause issues.

        Parameters:
        originalQueryString - URI query string (the part behind the question mark character).
        Returns:
        the same string with unsafe characters percent encoded.
      • reduceLeadingSlashes

        public static java.lang.String reduceLeadingSlashes​(java.lang.String path)
        Reduces the number of slashes before the path to only one slash.
        Parameters:
        path - path string
        Returns:
        path string with reduced slashes to only one.
      • getHandlerPath

        public static java.lang.String getHandlerPath​(java.lang.String uri)
        Splits URI address from query params and returns it.
        Parameters:
        uri - URI address in string format with query params
        Returns:
        URI address in string format without query params