Class RelativeRequestUri


  • public class RelativeRequestUri
    extends java.lang.Object
    URI path relative to a given index. An index represents the number of path components (portions of request uri separated by '/' character) preceding the start of the uri. For example:

     Request URI   Path Index   Relative URI 
    /a/b/c 0 /a/b/c
    /a/b/c 1 /b/c
    /a/b/c 3 (empty)
    • Constructor Summary

      Constructors 
      Constructor Description
      RelativeRequestUri​(javax.servlet.http.HttpServletRequest request, int pathIndex)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String[] getComponents()
      Gets components of the uri.
      java.lang.String getLastComponent()
      Gets the last component of request uri.
      java.lang.String getPrefix()
      Gets the absolute path from the context root to the start of the uri.
      javax.servlet.http.HttpServletRequest getRequest()
      Gets the original HTTP request.
      java.lang.String getUri()
      Gets the uri.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • RelativeRequestUri

        public RelativeRequestUri​(javax.servlet.http.HttpServletRequest request,
                                  int pathIndex)
        Constructor.
        Parameters:
        request - HTTP request
        pathIndex - index of the first path component relative to a servlet root (not context root!). Path components are parts of the request uri separated by '/' with the first component (servlet root) being assigned index zero.
        Throws:
        java.lang.IllegalArgumentException - if pathIndex is negative
    • Method Detail

      • getRequest

        public javax.servlet.http.HttpServletRequest getRequest()
        Gets the original HTTP request.
        Returns:
        HTTP request
      • getPrefix

        public java.lang.String getPrefix()
        Gets the absolute path from the context root to the start of the uri.
        Returns:
        uri prefix
      • getUri

        public java.lang.String getUri()
        Gets the uri.
        Returns:
        request uri
      • getComponents

        public java.lang.String[] getComponents()
        Gets components of the uri. The result is achieved by splitting request uri using '/' as separator.
        Returns:
        array of strings
      • getLastComponent

        public java.lang.String getLastComponent()
        Gets the last component of request uri.
        Returns:
        last uri component or null if request is empty
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object