Class HttpServerResponse

java.lang.Object
org.refcodes.web.AbstractHttpResponse
org.refcodes.web.HttpServerResponse
All Implemented Interfaces:
org.refcodes.mixin.Dumpable, HeaderFieldsAccessor<ResponseHeaderFields>, HttpBodyAccessor.HttpBodyProvider<BadResponseException>, HttpResponse, HttpStatusCodeAccessor, HttpStatusCodeAccessor.HttpStatusCodeBuilder<HttpServerResponse>, HttpStatusCodeAccessor.HttpStatusCodeMutator, HttpStatusCodeAccessor.HttpStatusCodeProperty

Defines a HttpServerResponse as produced by the server.
  • Field Details

  • Constructor Details

    • HttpServerResponse

      public HttpServerResponse(MediaTypeFactoryLookup aMediaTypeFactoryLookup)
      Instantiates a new http server response impl.
      Parameters:
      aMediaTypeFactoryLookup - the media type factory lookup
    • HttpServerResponse

      public HttpServerResponse(HttpStatusCode aHttpStatusCode, MediaTypeFactoryLookup aMediaTypeFactoryLookup)
      Instantiates a new http server response impl.
      Parameters:
      aHttpStatusCode - the http status code
      aMediaTypeFactoryLookup - the media type factory lookup
    • HttpServerResponse

      public HttpServerResponse(ResponseHeaderFields aResponseHeaderFields, MediaTypeFactoryLookup aMediaTypeFactoryLookup)
      Instantiates a new http server response impl.
      Parameters:
      aResponseHeaderFields - the response Header-Fields
      aMediaTypeFactoryLookup - the media type factory lookup
  • Method Details

    • withHttpStatusCode

      public HttpServerResponse withHttpStatusCode(HttpStatusCode aStatusCode)
      Sets the HTTP Status-Code for the HTTP Status-Code property.
      Specified by:
      withHttpStatusCode in interface HttpStatusCodeAccessor.HttpStatusCodeBuilder<HttpServerResponse>
      Parameters:
      aStatusCode - The HTTP Status-Code to be stored by the HTTP HTTP Status-Code property.
      Returns:
      The builder for applying multiple build operations.
    • withResponse

      public <RES> HttpServerResponse withResponse(RES aResponse)
      Sets the response for the response property.
      Type Parameters:
      RES - the generic type
      Parameters:
      aResponse - The response to be stored by the response property.
      Returns:
      The builder for applying multiple build operations.
    • getResponse

      public <RES> RES getResponse()
      Retrieves the response from the response property.
      Type Parameters:
      RES - the generic type
      Returns:
      The response stored by the response property.
    • setResponse

      public <RES> void setResponse(RES aResponse)
      Sets the response for the response property. The setResponse(Object) supports the HttpBodyMap to marshal an HttpBodyMap into an HTTP Request-Body.
      Type Parameters:
      RES - the generic type
      Parameters:
      aResponse - The response to be stored by the response property.
    • setHttpStatusCode

      public void setHttpStatusCode(HttpStatusCode aStatusCode)
      Sets the HTTP Status-Code for the HTTP Status-Code property.
      Specified by:
      setHttpStatusCode in interface HttpStatusCodeAccessor.HttpStatusCodeMutator
      Parameters:
      aStatusCode - The HTTP Status-Code to be stored by the HTTP HTTP Status-Code property.
    • toHttpBody

      public String toHttpBody() throws BadResponseException
      Converts an object representing the HTTP body to a String instance. Automatically determines the ContentType from any headers when applicable.
      Specified by:
      toHttpBody in interface HttpBodyAccessor.HttpBodyProvider<BadResponseException>
      Returns:
      The converted String instance represented by the according object.
      Throws:
      BadResponseException
    • toString

      public String toString()
      Overrides:
      toString in class Object