Class HTMLContext.Response

java.lang.Object
de.aristaflow.adept2.ui.htmlgui.HTMLContext.Response
All Implemented Interfaces:
TypedCloneable<HTMLContext.Response>, Closeable, AutoCloseable, Cloneable
Enclosing interface:
HTMLContext

public static class HTMLContext.Response extends Object implements Closeable, TypedCloneable<HTMLContext.Response>
A HTTP-response to be sent to the HTTP-client.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Deprecated, for removal: This API element is subject to removal in a future version.
    Use MediaType and MediaTypes instead.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final String
    MIME type of content, e. g.
    protected final int
    HTTP status code after processing, e. g.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
     
    Response(int status, InputStream data)
    Creates a response with the designated status and the designated data.
     
    Response(int status, InputStream data, String fileName)
    Creates a response with the designated status and the designated data.
     
    Response(int status, String txt)
    Creates a response with the designated status and the designated UTF-8-encoded plain text.
     
    Response(int status, String origMimeType, InputStream data)
    Creates a new HTTP-response with the designated status, MIME-type and data.
     
    Response(int status, String mimeType, String txt)
    Deprecated, for removal: This API element is subject to removal in a future version.
    protected
    Response(int status, String mimeType, Map<String,String> header)
    Creates a new response with the designated properties and no data.
     
    Response(int status, org.apache.tika.mime.MediaType mediaType, InputStream data)
    Creates a response with the designated status and the designated data using the designated media type.
     
    Response(int status, org.apache.tika.mime.MediaType mediaType, String txt)
    Creates a response with the designated status and the designated text using the designated media type.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addHeader(String name, String value)
    Adds the designated line to the header of this HTTP-response.
    Clones this object (usually via Object.clone()).
    void
     
    Deprecated, for removal: This API element is subject to removal in a future version.
    Use getInputStream() instead.
    Returns the additional response headers.
    Gets the response data as InputStream.
    Returns the mime type of the response.
    int
    Return the HTTP status code of the response.

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • status

      protected final int status
      HTTP status code after processing, e. g. ""200 OK", HTTP_OK
    • mimeType

      protected final String mimeType
      MIME type of content, e. g. "text/html".
  • Constructor Details

    • Response

      public Response(int status, String txt)
      Creates a response with the designated status and the designated UTF-8-encoded plain text.
      Parameters:
      status - The HTTP-status of the response to create.
      txt - The string which to send as UTF-8-encoded plain text.
      Throws:
      UncheckedIOException - If there are problems creating a RereadableContent from the designated txt, an UncheckedIOException will be thrown.
    • Response

      @Deprecated(since="14.0.0", forRemoval=true) public Response(int status, String mimeType, String txt)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Creates a response with the designated status and the designated text using the designated MIME type.
      Parameters:
      status - The HTTP-status of the response to create.
      mimeType - The MIME-type of the HTTP-response to create.
      txt - The string which to send as UTF-8-encoded plain text.
      Throws:
      UncheckedIOException - If there are problems creating a RereadableContent from the designated txt, an UncheckedIOException will be thrown.
    • Response

      public Response(int status, org.apache.tika.mime.MediaType mediaType, String txt)
      Creates a response with the designated status and the designated text using the designated media type.
      Parameters:
      status - The HTTP-status of the response to create.
      mediaType - The media type of the HTTP-response to create. This may be null.
      txt - The string which to send as UTF-8-encoded plain text.
      Throws:
      UncheckedIOException - If there are problems creating a RereadableContent from the designated txt, an UncheckedIOException will be thrown.
    • Response

      public Response(int status, InputStream data)
      Creates a response with the designated status and the designated data. The MIME type is determined from the data.
      Parameters:
      status - The HTTP-status of the response to create.
      data - The contents of the HTTP-response to create. The stream will be closed after the creation.
      Throws:
      UncheckedIOException - If there are problems reading from the designated stream or creating the corresponding RereadableContent, an UncheckedIOException will be thrown.
    • Response

      public Response(int status, InputStream data, String fileName)
      Creates a response with the designated status and the designated data. The MIME type is determined from the data and/or the designated file name.
      Parameters:
      status - The HTTP-status of the response to create.
      data - The contents of the HTTP-response to create. The stream will be closed after the creation.
      fileName - The name of the file the designated data represents. This is used to determine the MIME type. It may be null.
      Throws:
      UncheckedIOException - If there are problems reading from the designated stream or creating the corresponding RereadableContent, an UncheckedIOException will be thrown.
    • Response

      public Response(int status, String origMimeType, InputStream data)
      Creates a new HTTP-response with the designated status, MIME-type and data.
      Parameters:
      status - The HTTP-status of the response to create.
      origMimeType - The MIME-type of the HTTP-response to create. If this is null, the MIME type will be determined from the designated data.
      data - The contents of the HTTP-response to create. The stream will be closed after the creation.
      Throws:
      UncheckedIOException - If there are problems reading from the designated stream or creating the corresponding RereadableContent, an UncheckedIOException will be thrown.
    • Response

      public Response(int status, org.apache.tika.mime.MediaType mediaType, InputStream data)
      Creates a response with the designated status and the designated data using the designated media type. The caller has to make sure that this corresponds to the data.
      Parameters:
      status - The HTTP-status of the response to create.
      mediaType - The media type of the designated data. If this is null, the media type will be determined from the designated data.
      data - The contents of the HTTP-response to create. The stream will be closed after the creation.
      Throws:
      UncheckedIOException - If there are problems reading from the designated stream or creating the corresponding RereadableContent, an UncheckedIOException will be thrown.
    • Response

      protected Response(int status, String mimeType, Map<String,String> header)
      Creates a new response with the designated properties and no data. This allows for implementing wrappers in subclasses.
      Parameters:
      status - HTTP status code after processing, e. g. "200 OK", HTTP_OK.
      mimeType - MIME type of content, e. g. "text/html".
      header - Headers for the HTTP response. Use addHeader() to add lines.
  • Method Details

    • addHeader

      public void addHeader(String name, String value)
      Adds the designated line to the header of this HTTP-response.
      Parameters:
      name - The name of the header-field to add to this HTTP-response.
      value - The value of the header-field to add to this HTTP-response.
    • getStatus

      public int getStatus()
      Return the HTTP status code of the response.
      Returns:
      The HTTP status code of the response.
    • getMimeType

      public String getMimeType()
      Returns the mime type of the response.
      Returns:
      The mime type of the response.
    • getData

      @Deprecated(since="15.0.0", forRemoval=true) public InputStream getData()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use getInputStream() instead.
      Returns the response data.
      Returns:
      The response data. The caller is responsible for closing.
      Throws:
      UncheckedIOException - If there are problems creating a new InputStream for the data, an IOException will be thrown.
    • getInputStream

      public InputStream getInputStream() throws IOException
      Gets the response data as InputStream.
      Returns:
      The response data as InputStream. The caller is responsible for closing.
      Throws:
      IOException - If there are problems creating a new InputStream for the data, an IOException will be thrown.
    • getHeader

      public Map<String,String> getHeader()
      Returns the additional response headers.
      Returns:
      Additional response headers.
    • clone

      public HTMLContext.Response clone()
      Description copied from interface: TypedCloneable
      Clones this object (usually via Object.clone()).
      Specified by:
      clone in interface TypedCloneable<HTMLContext.Response>
      Overrides:
      clone in class Object
      Returns:
      A clone of the implementing object.
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException