Class HttpRequest

  • Direct Known Subclasses:
    LayeredRequest

    public class HttpRequest
    extends HttpPackage
    This particular kind of package contains the request information.
    Author:
    javaito
    • Constructor Detail

      • HttpRequest

        public HttpRequest​(java.lang.String requestPath,
                           HttpMethod method)
      • HttpRequest

        protected HttpRequest​(HttpRequest httpRequest)
      • HttpRequest

        public HttpRequest()
    • Method Detail

      • getPath

        public final java.lang.String getPath()
        Return the request path
        Returns:
        Request path.
      • setPath

        public final void setPath​(java.lang.String path)
        Set the request path.
        Parameters:
        path - Request path.
      • getContext

        public final java.lang.String getContext()
        Return the request context.
        Returns:
        Request context.
      • setContext

        public final void setContext​(java.lang.String context)
        Set the request context.
        Parameters:
        context - Request context.
      • getMethod

        public final HttpMethod getMethod()
        Return the request method.
        Returns:
        Request method.
      • setMethod

        public final void setMethod​(HttpMethod method)
        Set the request method.
        Parameters:
        method - Request method.
      • hasParameter

        public final boolean hasParameter​(java.lang.String name)
        Returns true if the request contains the parameter indicated.
        Parameters:
        name - Name of the parameter.
        Returns:
        True if the parameter is present and false in the otherwise.
      • getParameters

        public final java.util.Map<java.lang.String,​java.lang.Object> getParameters()
        Return the request parameters.
        Returns:
        Request parameters.
      • getParameter

        public final <O> O getParameter​(java.lang.String parameterName)
        Return the parameter indexed by the argument name.
        Type Parameters:
        O - Expected response type
        Parameters:
        parameterName - Name of the founding parameter.
        Returns:
        Return the parameter.
      • getReplaceableValue

        public final java.lang.String getReplaceableValue​(java.lang.String placeName)
        Returns the value that corresponds with the place named with the name indicated.
        Parameters:
        placeName - Name of the place.
        Returns:
        Value replaced into the place.
      • setMatcher

        public final void setMatcher​(java.util.regex.Matcher matcher)
        This method set the matche that results of the match between the context regex and the url invoked with the request.
        Parameters:
        matcher - Matcher instance.
      • addHttpParameter

        public final void addHttpParameter​(java.lang.String parameterName,
                                           java.lang.String parameterValue)
        Add parameter.
        Parameters:
        parameterName - Parameter name.
        parameterValue - Parameter value.
      • getPathParts

        public final java.util.List<java.lang.String> getPathParts()
        Return a list with all the parts of the request path. If the path is /path1/path2/pathN, then the method response with a list ad [path1,path2,pathN]
        Returns:
        List with all the parts of the request path.
      • processBody

        protected void processBody()
        This method process the body of the complete request.
        Specified by:
        processBody in class HttpPackage
      • processFirstLine

        protected void processFirstLine​(java.lang.String firstLine)
        Process the first line of the request.
        Specified by:
        processFirstLine in class HttpPackage
        Parameters:
        firstLine - First line of the request.
      • getProtocolHeader

        public final byte[] getProtocolHeader()
        Return the bytes that represent the string of the protocol name.
        Specified by:
        getProtocolHeader in class HttpPackage
        Returns:
        Protocol name bytes.
      • toString

        public java.lang.String toString()
        Creates the string representation of the package.
        Overrides:
        toString in class java.lang.Object
        Returns:
        String representation of the package.