Class PathInfoProcessor


  • public class PathInfoProcessor
    extends java.lang.Object
    This class splits path info string which has format /name1/value1/name2/value2/rest and returns values corresponding to names. NEW: now supports paths like name1/va/lue1/name2/value2/rest For invocation PathInfoProcessor(req, 'name1', 'name2') getString(name1) == va getPath(name1) == va/lue1 getString(name2) == getPath(name2) == value2 getRestPath() == rest I.e. you can ask for value by given parameter name getString(String). Parameter names are passed via constructor PathInfoProcessor(javax.servlet.http.HttpServletRequest, java.lang.String...). All the string starting from unknown parameter name goes to rest path getRestPath() .
    Author:
    Kir
    • Constructor Summary

      Constructors 
      Constructor Description
      PathInfoProcessor​(javax.servlet.http.HttpServletRequest request, java.lang.String... parameters)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getPath​(java.lang.String param)
      get path value by parameter name, may include several parts separated by /
      java.lang.String getRestPath()
      return rest path in path info, i.e.
      java.lang.String getString​(java.lang.String param)
      get value by parameter name, won't include subsequent parts
      • Methods inherited from class java.lang.Object

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

      • PathInfoProcessor

        public PathInfoProcessor​(javax.servlet.http.HttpServletRequest request,
                                 java.lang.String... parameters)
        Parameters:
        request - request object to as PathInfo from via HttpServletRequest.getPathInfo()
        parameters - possible names of parameters (param1 and param2 for expected string /param1/value1/param2/value2/restPath)
    • Method Detail

      • getString

        @Nullable
        public java.lang.String getString​(java.lang.String param)
        get value by parameter name, won't include subsequent parts
        Parameters:
        param - name of parameter
        Returns:
        value, like value1
      • getPath

        @Nullable
        public java.lang.String getPath​(java.lang.String param)
        get path value by parameter name, may include several parts separated by /
        Parameters:
        param - name of parameter
        Returns:
        value, like part/of/value1
      • getRestPath

        @NotNull
        public java.lang.String getRestPath()
        return rest path in path info, i.e. path without known parameters
        Returns:
        see above