Class SmallResponse.GenericSmallResponse

java.lang.Object
com.blackrook.small.SmallResponse.GenericSmallResponse
All Implemented Interfaces:
SmallResponse, AutoCloseable
Enclosing interface:
SmallResponse

public static class SmallResponse.GenericSmallResponse extends Object implements SmallResponse
Creates a generic response object for Small Responses.
Since:
1.4.0
  • Method Details

    • status

      public SmallResponse.GenericSmallResponse status(int status)
      Sets the status on this response.
      Parameters:
      status - the status code.
      Returns:
      itself, for call chaining.
    • header

      public SmallResponse.GenericSmallResponse header(String headerName, String value)
      Sets a header value. If this header was added more than once, it is cleared before the add.
      Parameters:
      headerName - the header name.
      value - the corresponding value.
      Returns:
      itself, for call chaining.
    • dateHeader

      public SmallResponse.GenericSmallResponse dateHeader(String headerName, Date value)
      Sets a header date value. If this header was added more than once, it is cleared before the add.
      Parameters:
      headerName - the header name.
      value - the corresponding date value.
      Returns:
      itself, for call chaining.
      Since:
      1.2.0
    • dateHeader

      public SmallResponse.GenericSmallResponse dateHeader(String headerName, long value)
      Sets a header date value. If this header was added more than once, it is cleared before the add.
      Parameters:
      headerName - the header name.
      value - the corresponding value.
      Returns:
      itself, for call chaining.
      Since:
      1.2.0
    • addHeader

      public SmallResponse.GenericSmallResponse addHeader(String headerName, String value)
      Adds a header value.
      Parameters:
      headerName - the header name.
      value - the corresponding value.
      Returns:
      itself, for call chaining.
    • addDateHeader

      public SmallResponse.GenericSmallResponse addDateHeader(String headerName, Date value)
      Adds a header date value.
      Parameters:
      headerName - the header name.
      value - the corresponding date value.
      Returns:
      itself, for call chaining.
      Since:
      1.2.0
    • addDateHeader

      public SmallResponse.GenericSmallResponse addDateHeader(String headerName, long value)
      Adds a header date value.
      Parameters:
      headerName - the header name.
      value - the corresponding date value in milliseconds since the Epoch.
      Returns:
      itself, for call chaining.
      Since:
      1.2.0
    • content

      public SmallResponse.GenericSmallResponse content(Object content)
      Sets the content of the response.
      Parameters:
      content - the content.
      Returns:
      itself, for call chaining.
    • type

      Sets the MIME-Type (content type) header for the response.
      Parameters:
      mimeType - the MIME-Type.
      Returns:
      itself, for call chaining.
    • type

      public SmallResponse.GenericSmallResponse type(String mimeType, String charset)
      Sets the MIME-Type (content type) header for the response.
      Parameters:
      mimeType - the MIME-Type.
      charset - the charset name.
      Returns:
      itself, for call chaining.
    • attachment

      Sets that this response is an attachment.
      Returns:
      itself, for call chaining.
    • attachment

      public SmallResponse.GenericSmallResponse attachment(String fileName)
      Sets that this response is an attachment with a filename.
      Parameters:
      fileName - the file name.
      Returns:
      itself, for call chaining.
    • getStatus

      public int getStatus()
      Specified by:
      getStatus in interface SmallResponse
      Returns:
      the status code.
    • getHeaders

      public Map<String,List<String>> getHeaders()
      Specified by:
      getHeaders in interface SmallResponse
      Returns:
      the header map.
    • getContent

      public Object getContent()
      Specified by:
      getContent in interface SmallResponse
      Returns:
      the response content.
    • close

      public void close() throws Exception
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface SmallResponse
      Throws:
      Exception