Package com.aspectran.core.adapter
Interface ResponseAdapter
-
- All Known Implementing Classes:
AbstractResponseAdapter,DefaultResponseAdapter,QuartzJobResponseAdapter
public interface ResponseAdapterThe Interface ResponseAdapter.- Since:
- 2011. 3. 13.
-
-
Method Summary
All Methods Instance Methods Abstract 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.<T> TgetAdaptee()Returns the adaptee object to provide response information.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.Collection<java.lang.String>getHeaderNames()Returns the names of the headers of this response.java.util.Collection<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.voidsetStatus(int status)Sets the status code.
-
-
-
Method Detail
-
getAdaptee
<T> T getAdaptee()
Returns the adaptee object to provide response information.- Type Parameters:
T- the type of the adaptee object- Returns:
- the adaptee object
-
getHeader
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
java.util.Collection<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
java.util.Collection<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
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
void setHeader(java.lang.String name, java.lang.String value)Set the given single header value under the given header name. If the header had already been set, the new value overwrites the previous one.- Parameters:
name- the header namevalue- the header value to set
-
addHeader
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
-
getEncoding
java.lang.String getEncoding()
Returns 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
void setEncoding(java.lang.String encoding) throws java.io.UnsupportedEncodingExceptionSets 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)- Throws:
java.io.UnsupportedEncodingException- if character encoding is not supported
-
getContentType
java.lang.String getContentType()
Returns 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
void setContentType(java.lang.String contentType)
Sets 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
java.io.OutputStream getOutputStream() throws java.io.IOExceptionReturns aOutputStreamsuitable for writing binary data in the response.- Returns:
- a
OutputStreamfor writing binary data - Throws:
java.io.IOException- if an input or output exception occurs
-
getWriter
java.io.Writer getWriter() throws java.io.IOExceptionReturns aWriterobject that can send character text to the client.- Returns:
- a
Writerobject that can return character data to the client - Throws:
java.io.IOException- if an input or output exception occurs
-
flush
void flush() throws java.io.IOExceptionForces any content in the buffer to be written to the client.- Throws:
java.io.IOException- if an input or output exception occurs
-
redirect
void redirect(java.lang.String path) throws java.io.IOExceptionRedirects a client to a new URL.- Parameters:
path- the redirect path- Throws:
java.io.IOException- if an input or output exception occurs
-
redirect
java.lang.String redirect(RedirectRule redirectRule) throws java.io.IOException
Redirects a client to a new URL.- Parameters:
redirectRule- the redirect rule- Returns:
- the redirect path
- Throws:
java.io.IOException- if an input or output exception occurs
-
getStatus
int getStatus()
Returns the status code.- Returns:
- the status
-
setStatus
void setStatus(int status)
Sets the status code.- Parameters:
status- the status code
-
-