Class PathInfoProcessor


  • public class PathInfoProcessor
    extends 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 Detail

      • PathInfoProcessor

        public PathInfoProcessor​(javax.servlet.http.HttpServletRequest request,
                                 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 String getString​(String param)
        get value by parameter name, won't include subsequent parts
        Parameters:
        param - name of parameter
        Returns:
        value, like value1
      • getPath

        @Nullable
        public String getPath​(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 String getRestPath()
        return rest path in path info, i.e. path without known parameters
        Returns:
        see above