Package com.aspectran.core.adapter
Class DefaultResponseAdapter
- java.lang.Object
-
- com.aspectran.core.adapter.AbstractResponseAdapter
-
- com.aspectran.core.adapter.DefaultResponseAdapter
-
- All Implemented Interfaces:
ResponseAdapter
- Direct Known Subclasses:
QuartzJobResponseAdapter
public class DefaultResponseAdapter extends AbstractResponseAdapter
The Class DefaultResponseAdapter.- Since:
- 2016. 2. 13.
-
-
Constructor Summary
Constructors Constructor Description DefaultResponseAdapter(java.lang.Object adaptee)Instantiates a new default response adapter.DefaultResponseAdapter(java.lang.Object adaptee, java.io.Writer writer)Instantiates a new default response adapter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddHeader(java.lang.String name, java.lang.String value)Add the given single header value to the current list of values for the given header.booleancontainsHeader(java.lang.String name)Returns a boolean indicating whether the named response header has already been set.voidflush()Forces any content in the buffer to be written to the client.MultiValueMap<java.lang.String,java.lang.String>getAllHeaders()Returns a map of the request headers that can be modified.java.lang.StringgetContentType()Returns the content type used for the MIME body sent in this response.java.lang.StringgetEncoding()Returns the name of the character encoding (MIME charset) used for the body sent in this response.java.lang.StringgetHeader(java.lang.String name)Returns the value of the response header with the given name.java.util.Set<java.lang.String>getHeaderNames()Returns the names of the headers of this response.java.util.List<java.lang.String>getHeaders(java.lang.String name)Returns the values of the response header with the given name.java.io.OutputStreamgetOutputStream()Returns aOutputStreamsuitable for writing binary data in the response.intgetStatus()Returns the status code.java.io.WritergetWriter()Returns aWriterobject that can send character text to the client.java.lang.Stringredirect(RedirectRule redirectRule)Redirects a client to a new URL.voidredirect(java.lang.String path)Redirects a client to a new URL.voidsetContentType(java.lang.String contentType)Sets the content type of the response being sent to the client, if the response has not been committed yet.voidsetEncoding(java.lang.String encoding)Sets the character encoding of the response being sent to the client.voidsetHeader(java.lang.String name, java.lang.String value)Set the given single header value under the given header name.protected voidsetOutputStream(java.io.OutputStream outputStream)voidsetStatus(int status)Sets the status code.protected voidsetWriter(java.io.Writer writer)MultiValueMap<java.lang.String,java.lang.String>touchHeaders()Returns a map of the response headers that can be modified.-
Methods inherited from class com.aspectran.core.adapter.AbstractResponseAdapter
getAdaptee
-
-
-
-
Constructor Detail
-
DefaultResponseAdapter
public DefaultResponseAdapter(java.lang.Object adaptee)
Instantiates a new default response adapter.- Parameters:
adaptee- the adaptee object
-
DefaultResponseAdapter
public DefaultResponseAdapter(java.lang.Object adaptee, java.io.Writer writer)Instantiates a new default response adapter.- Parameters:
adaptee- the adaptee objectwriter- the writer to output
-
-
Method Detail
-
getHeader
public java.lang.String getHeader(java.lang.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
nullif no header with the given name has been set on this response
-
getHeaders
public java.util.List<java.lang.String> getHeaders(java.lang.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)
Collectionof the values of the response header with the given name
-
getHeaderNames
public java.util.Set<java.lang.String> getHeaderNames()
Returns the names of the headers of this response.- Returns:
- a (possibly empty)
Collectionof the names of the headers of this response
-
containsHeader
public boolean containsHeader(java.lang.String name)
Returns a boolean indicating whether the named response header has already been set.- Parameters:
name- the header name- Returns:
trueif the named response header has already been set;falseotherwise
-
setHeader
public void setHeader(java.lang.String name, java.lang.String value)Set the given single header value under the given header name.- Parameters:
name- the header namevalue- the header value to set
-
addHeader
public void addHeader(java.lang.String name, java.lang.String value)Add the given single header value to the current list of values for the given header.- Parameters:
name- the header namevalue- the header value to be added
-
getAllHeaders
public MultiValueMap<java.lang.String,java.lang.String> getAllHeaders()
Returns a map of the request headers that can be modified.- Returns:
- an
MultiValueMapobject, may benull
-
touchHeaders
public MultiValueMap<java.lang.String,java.lang.String> touchHeaders()
Returns a map of the response headers that can be modified. If not yet instantiated then create a new one.- Returns:
- an
MultiValueMapobject, may not benull
-
getEncoding
public java.lang.String getEncoding()
Description copied from interface:ResponseAdapterReturns the name of the character encoding (MIME charset) used for the body sent in this response.- Returns:
- a
Stringspecifying the name of the character encoding, for example, UTF-8
-
setEncoding
public void setEncoding(java.lang.String encoding)
Description copied from interface:ResponseAdapterSets the character encoding of the response being sent to the client.- Parameters:
encoding- aStringspecifying only the character set defined by IANA Character Sets (http://www.iana.org/assignments/character-sets)
-
getContentType
public java.lang.String getContentType()
Description copied from interface:ResponseAdapterReturns the content type used for the MIME body sent in this response.- Returns:
- a
Stringspecifying the content type, for example,text/html, or null
-
setContentType
public void setContentType(java.lang.String contentType)
Description copied from interface:ResponseAdapterSets the content type of the response being sent to the client, if the response has not been committed yet.- Parameters:
contentType- aStringspecifying the MIME type of the content
-
getOutputStream
public java.io.OutputStream getOutputStream()
Description copied from interface:ResponseAdapterReturns aOutputStreamsuitable for writing binary data in the response.- Returns:
- a
OutputStreamfor writing binary data
-
setOutputStream
protected void setOutputStream(java.io.OutputStream outputStream)
-
getWriter
public java.io.Writer getWriter()
Description copied from interface:ResponseAdapterReturns aWriterobject that can send character text to the client.- Returns:
- a
Writerobject that can return character data to the client
-
setWriter
protected void setWriter(java.io.Writer writer)
-
flush
public void flush() throws java.io.IOExceptionDescription copied from interface:ResponseAdapterForces any content in the buffer to be written to the client.- Throws:
java.io.IOException- if an input or output exception occurs
-
redirect
public void redirect(java.lang.String path)
Description copied from interface:ResponseAdapterRedirects a client to a new URL.- Parameters:
path- the redirect path
-
redirect
public java.lang.String redirect(RedirectRule redirectRule)
Description copied from interface:ResponseAdapterRedirects 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
-
-