Class DefaultResponseAdapter

java.lang.Object
com.aspectran.core.adapter.AbstractResponseAdapter
com.aspectran.core.adapter.DefaultResponseAdapter
All Implemented Interfaces:
ResponseAdapter
Direct Known Subclasses:
AspectranResponseAdapter, DaemonResponseAdapter, QuartzJobResponseAdapter, ShellResponseAdapter

public class DefaultResponseAdapter extends AbstractResponseAdapter
The Class DefaultResponseAdapter.
Since:
2016. 2. 13.
  • Constructor Details

    • DefaultResponseAdapter

      public DefaultResponseAdapter(Object adaptee)
      Instantiates a new default response adapter.
      Parameters:
      adaptee - the adaptee object
    • DefaultResponseAdapter

      public DefaultResponseAdapter(Object adaptee, Writer writer)
      Instantiates a new default response adapter.
      Parameters:
      adaptee - the adaptee object
      writer - the writer to output
  • Method Details

    • getHeader

      public String getHeader(String name)
      Returns the value of the response header with the given name.

      If a response header with the given name exists and contains multiple values, the value that was added first will be returned.

      Parameters:
      name - the name of the response header whose value to return
      Returns:
      the value of the response header with the given name, or null if no header with the given name has been set on this response
    • getHeaders

      public List<String> getHeaders(String name)
      Returns the values of the response header with the given name.
      Parameters:
      name - the name of the response header whose values to return
      Returns:
      a (possibly empty) Collection of the values of the response header with the given name
    • getHeaderNames

      public Set<String> getHeaderNames()
      Returns the names of the headers of this response.
      Returns:
      a (possibly empty) Collection of the names of the headers of this response
    • containsHeader

      public boolean containsHeader(String name)
      Returns a boolean indicating whether the named response header has already been set.
      Parameters:
      name - the header name
      Returns:
      true if the named response header has already been set; false otherwise
    • setHeader

      public void setHeader(String name, String value)
      Set the given single header value under the given header name.
      Parameters:
      name - the header name
      value - the header value to set
    • addHeader

      public void addHeader(String name, String value)
      Add the given single header value to the current list of values for the given header.
      Parameters:
      name - the header name
      value - the header value to be added
    • getAllHeaders

      public MultiValueMap<String,String> getAllHeaders()
      Returns a map of the request headers that can be modified.
      Returns:
      an MultiValueMap object, may be null
    • touchHeaders

      public MultiValueMap<String,String> touchHeaders()
      Returns a map of the response headers that can be modified. If not yet instantiated then create a new one.
      Returns:
      an MultiValueMap object, may not be null
    • getEncoding

      public String getEncoding()
      Description copied from interface: ResponseAdapter
      Returns the name of the character encoding (MIME charset) used for the body sent in this response.
      Returns:
      a String specifying the name of the character encoding, for example, UTF-8
    • setEncoding

      public void setEncoding(String encoding)
      Description copied from interface: ResponseAdapter
      Sets the character encoding of the response being sent to the client.
      Parameters:
      encoding - a String specifying only the character set defined by IANA Character Sets (http://www.iana.org/assignments/character-sets)
    • getContentType

      public String getContentType()
      Description copied from interface: ResponseAdapter
      Returns the content type used for the MIME body sent in this response.
      Returns:
      a String specifying the content type, for example, text/html, or null
    • setContentType

      public void setContentType(String contentType)
      Description copied from interface: ResponseAdapter
      Sets the content type of the response being sent to the client, if the response has not been committed yet.
      Parameters:
      contentType - a String specifying the MIME type of the content
    • getOutputStream

      public OutputStream getOutputStream()
      Description copied from interface: ResponseAdapter
      Returns a OutputStream suitable for writing binary data in the response.
      Returns:
      a OutputStream for writing binary data
    • setOutputStream

      protected void setOutputStream(OutputStream outputStream)
    • getWriter

      public Writer getWriter()
      Description copied from interface: ResponseAdapter
      Returns a Writer object that can send character text to the client.
      Returns:
      a Writer object that can return character data to the client
    • setWriter

      protected void setWriter(Writer writer)
    • flush

      public void flush() throws IOException
      Description copied from interface: ResponseAdapter
      Forces any content in the buffer to be written to the client.
      Throws:
      IOException - if an input or output exception occurs
    • redirect

      public void redirect(String location)
      Description copied from interface: ResponseAdapter
      Sends a temporary redirect response to the client using the specified redirect location.
      Parameters:
      location - the redirect location
    • redirect

      public String redirect(RedirectRule redirectRule)
      Description copied from interface: ResponseAdapter
      Redirects a client to a new URL.
      Parameters:
      redirectRule - the redirect rule
      Returns:
      the redirect path
    • getStatus

      public int getStatus()
      Returns the status code.
      Returns:
      the status
    • setStatus

      public void setStatus(int status)
      Sets the status code.
      Parameters:
      status - the status code