public class DummyResponse extends Object implements HttpResponse, javax.servlet.http.HttpServletResponse
SC_ACCEPTED, SC_BAD_GATEWAY, SC_BAD_REQUEST, SC_CONFLICT, SC_CONTINUE, SC_CREATED, SC_EXPECTATION_FAILED, SC_FORBIDDEN, SC_FOUND, SC_GATEWAY_TIMEOUT, SC_GONE, SC_HTTP_VERSION_NOT_SUPPORTED, SC_INTERNAL_SERVER_ERROR, SC_LENGTH_REQUIRED, SC_METHOD_NOT_ALLOWED, SC_MOVED_PERMANENTLY, SC_MOVED_TEMPORARILY, SC_MULTIPLE_CHOICES, SC_NO_CONTENT, SC_NON_AUTHORITATIVE_INFORMATION, SC_NOT_ACCEPTABLE, SC_NOT_FOUND, SC_NOT_IMPLEMENTED, SC_NOT_MODIFIED, SC_OK, SC_PARTIAL_CONTENT, SC_PAYMENT_REQUIRED, SC_PRECONDITION_FAILED, SC_PROXY_AUTHENTICATION_REQUIRED, SC_REQUEST_ENTITY_TOO_LARGE, SC_REQUEST_TIMEOUT, SC_REQUEST_URI_TOO_LONG, SC_REQUESTED_RANGE_NOT_SATISFIABLE, SC_RESET_CONTENT, SC_SEE_OTHER, SC_SERVICE_UNAVAILABLE, SC_SWITCHING_PROTOCOLS, SC_TEMPORARY_REDIRECT, SC_UNAUTHORIZED, SC_UNSUPPORTED_MEDIA_TYPE, SC_USE_PROXY
Constructor and Description |
---|
DummyResponse() |
Modifier and Type | Method and Description |
---|---|
void |
addCookie(javax.servlet.http.Cookie cookie) |
void |
addDateHeader(String name,
long value) |
void |
addHeader(String name,
String value) |
void |
addIntHeader(String name,
int value) |
void |
addSessionCookieInternal(javax.servlet.http.Cookie cookie)
Special method for adding a session cookie as we should be overriding
any previous
|
boolean |
containsHeader(String name) |
javax.servlet.ServletOutputStream |
createOutputStream()
Create and return a ServletOutputStream to write the content
associated with this Response.
|
String |
encode(String url)
Apply URL Encoding to the given URL without adding session identifier
et al associated to this response.
|
String |
encodeRedirectUrl(String url) |
String |
encodeRedirectURL(String url) |
String |
encodeUrl(String url) |
String |
encodeURL(String url) |
void |
finishResponse()
Perform whatever actions are required to flush and close the output
stream or writer, in a single operation.
|
void |
flushBuffer() |
int |
getBufferSize() |
String |
getCharacterEncoding() |
Connector |
getConnector()
Return the Connector through which this Response is returned.
|
int |
getContentCount()
Return the number of bytes actually written to the output stream.
|
int |
getContentLength()
Return the content length that was set or calculated for this Response.
|
String |
getContentType()
Return the content type that was set or calculated for this response,
or
null if no content type was set. |
Context |
getContext()
Return the Context with which this Response is associated.
|
String |
getDetailMessage()
Gets detail error message.
|
String |
getHeader(String name)
Return the value for the specified header, or
null if this
header has not been set. |
Collection<String> |
getHeaderNames() |
Collection<String> |
getHeaders(String name) |
boolean |
getIncluded()
Return the "processing inside an include" flag.
|
String |
getInfo()
Return descriptive information about this Response implementation and
the corresponding version number, in the format
<description>/<version> . |
Locale |
getLocale() |
String |
getMessage()
Return the error message that was set with
sendError()
for this Response. |
javax.servlet.ServletOutputStream |
getOutputStream() |
PrintWriter |
getReporter()
Return a PrintWriter that can be used to render error messages,
regardless of whether a stream or writer has already been acquired.
|
Request |
getRequest()
Return the Request with which this Response is associated.
|
javax.servlet.ServletResponse |
getResponse()
Return the
ServletResponse for which this object
is the facade. |
int |
getStatus()
Return the HTTP status code associated with this Response.
|
OutputStream |
getStream()
Return the output stream associated with this Response.
|
PrintWriter |
getWriter() |
boolean |
isAppCommitted()
Application commit flag accessor.
|
boolean |
isCommitted() |
boolean |
isError()
Error flag accessor.
|
boolean |
isSuspended()
Suspended flag accessor.
|
void |
recycle()
Release all object references, and initialize instance variables, in
preparation for reuse of this object.
|
void |
reset() |
void |
reset(int status,
String message)
Reset this response, and specify the values for the HTTP status code
and corresponding message.
|
void |
resetBuffer()
Reset the data buffer but not any status or header information.
|
void |
resetBuffer(boolean resetWriterStreamFlags)
Reset the data buffer and the using Writer/Stream flags but not any
status or header information.
|
void |
sendAcknowledgement()
Send an acknowledgment of a request.
|
void |
sendError(int status) |
void |
sendError(int status,
String message) |
void |
sendRedirect(String location) |
void |
setAppCommitted(boolean appCommitted)
Set the application commit flag.
|
void |
setBufferSize(int size) |
void |
setCharacterEncoding(String charEncoding) |
void |
setConnector(Connector connector)
Set the Connector through which this Response is returned.
|
void |
setContentLength(int length) |
void |
setContentLengthLong(long length) |
void |
setContentType(String type) |
void |
setContext(Context context)
Set the Context with which this Response is associated.
|
void |
setDateHeader(String name,
long value) |
void |
setDetailMessage(String msg)
Sets detail error message.
|
void |
setError()
Set the error flag.
|
void |
setHeader(String name,
String value) |
void |
setIncluded(boolean included)
Set the "processing inside an include" flag.
|
void |
setIntHeader(String name,
int value) |
void |
setLocale(Locale locale) |
void |
setRequest(Request request)
Set the Request with which this Response is associated.
|
void |
setStatus(int status) |
void |
setStatus(int status,
String message) |
void |
setStream(OutputStream stream)
Set the output stream associated with this Response.
|
void |
setSuspended(boolean suspended)
Set the suspended flag.
|
void |
write(byte[] b) |
void |
write(byte[] b,
int off,
int len) |
void |
write(int b) |
public void setAppCommitted(boolean appCommitted)
Response
setAppCommitted
in interface Response
appCommitted
- The new application committed flag valuepublic boolean isAppCommitted()
Response
isAppCommitted
in interface Response
public Connector getConnector()
Response
getConnector
in interface Response
public void setConnector(Connector connector)
Response
setConnector
in interface Response
connector
- The new connectorpublic int getContentCount()
Response
getContentCount
in interface Response
public Context getContext()
Response
getContext
in interface Response
public void setContext(Context context)
Response
setContext
in interface Response
context
- The associated Contextpublic boolean getIncluded()
Response
getIncluded
in interface Response
public void setIncluded(boolean included)
Response
setIncluded
in interface Response
included
- true
if we are currently inside a
RequestDispatcher.include(), else false
public String getInfo()
Response
<description>/<version>
.public Request getRequest()
Response
getRequest
in interface Response
public void setRequest(Request request)
Response
setRequest
in interface Response
request
- The new associated requestpublic javax.servlet.ServletResponse getResponse()
Response
ServletResponse
for which this object
is the facade.getResponse
in interface Response
public OutputStream getStream()
Response
public void setStream(OutputStream stream)
Response
public void setSuspended(boolean suspended)
Response
setSuspended
in interface Response
suspended
- The new suspended flag valuepublic boolean isSuspended()
Response
isSuspended
in interface Response
public void setError()
Response
public boolean isError()
Response
public javax.servlet.ServletOutputStream createOutputStream() throws IOException
Response
createOutputStream
in interface Response
IOException
- if an input/output error occurspublic void finishResponse() throws IOException
Response
finishResponse
in interface Response
IOException
- if an input/output error occurspublic int getContentLength()
Response
getContentLength
in interface Response
public String getContentType()
Response
null
if no content type was set.getContentType
in interface javax.servlet.ServletResponse
getContentType
in interface Response
public PrintWriter getReporter()
Response
getReporter
in interface Response
public void recycle()
Response
public void write(int b) throws IOException
IOException
public void write(byte[] b) throws IOException
IOException
public void write(byte[] b, int off, int len) throws IOException
IOException
public void flushBuffer() throws IOException
flushBuffer
in interface javax.servlet.ServletResponse
IOException
public int getBufferSize()
getBufferSize
in interface javax.servlet.ServletResponse
public String getCharacterEncoding()
getCharacterEncoding
in interface javax.servlet.ServletResponse
public void setCharacterEncoding(String charEncoding)
setCharacterEncoding
in interface javax.servlet.ServletResponse
public javax.servlet.ServletOutputStream getOutputStream() throws IOException
getOutputStream
in interface javax.servlet.ServletResponse
IOException
public Locale getLocale()
getLocale
in interface javax.servlet.ServletResponse
public PrintWriter getWriter() throws IOException
getWriter
in interface javax.servlet.ServletResponse
IOException
public boolean isCommitted()
isCommitted
in interface javax.servlet.ServletResponse
public void reset()
reset
in interface javax.servlet.ServletResponse
public void resetBuffer()
Response
resetBuffer
in interface javax.servlet.ServletResponse
resetBuffer
in interface Response
public void resetBuffer(boolean resetWriterStreamFlags)
Response
resetBuffer
in interface Response
public void setBufferSize(int size)
setBufferSize
in interface javax.servlet.ServletResponse
public void setContentLength(int length)
setContentLength
in interface javax.servlet.ServletResponse
public void setContentLengthLong(long length)
setContentLengthLong
in interface javax.servlet.ServletResponse
public void setContentType(String type)
setContentType
in interface javax.servlet.ServletResponse
public void setLocale(Locale locale)
setLocale
in interface javax.servlet.ServletResponse
public String getHeader(String name)
HttpResponse
null
if this
header has not been set. If more than one value was added for this
name, only the first is returned; use HttpResponse.getHeaders(String)
to
retrieve all of them.getHeader
in interface javax.servlet.http.HttpServletResponse
getHeader
in interface HttpResponse
name
- Header name to look uppublic Collection<String> getHeaderNames()
getHeaderNames
in interface javax.servlet.http.HttpServletResponse
getHeaderNames
in interface HttpResponse
Collection
of the names
of the headers of this responsepublic Collection<String> getHeaders(String name)
getHeaders
in interface javax.servlet.http.HttpServletResponse
getHeaders
in interface HttpResponse
name
- the name of the response header whose values to returnCollection
of the values
of the response header with the given namepublic void addSessionCookieInternal(javax.servlet.http.Cookie cookie)
HttpResponse
addSessionCookieInternal
in interface HttpResponse
public String getMessage()
HttpResponse
sendError()
for this Response.getMessage
in interface HttpResponse
public int getStatus()
HttpResponse
getStatus
in interface javax.servlet.http.HttpServletResponse
getStatus
in interface HttpResponse
public void reset(int status, String message)
HttpResponse
reset
in interface HttpResponse
public void addCookie(javax.servlet.http.Cookie cookie)
addCookie
in interface javax.servlet.http.HttpServletResponse
public void addDateHeader(String name, long value)
addDateHeader
in interface javax.servlet.http.HttpServletResponse
public void addHeader(String name, String value)
addHeader
in interface javax.servlet.http.HttpServletResponse
public void addIntHeader(String name, int value)
addIntHeader
in interface javax.servlet.http.HttpServletResponse
public boolean containsHeader(String name)
containsHeader
in interface javax.servlet.http.HttpServletResponse
public String encodeRedirectURL(String url)
encodeRedirectURL
in interface javax.servlet.http.HttpServletResponse
public String encodeRedirectUrl(String url)
encodeRedirectUrl
in interface javax.servlet.http.HttpServletResponse
public String encodeURL(String url)
encodeURL
in interface javax.servlet.http.HttpServletResponse
public String encodeUrl(String url)
encodeUrl
in interface javax.servlet.http.HttpServletResponse
public String encode(String url)
Response
public void sendAcknowledgement() throws IOException
HttpResponse
HTTP/1.1 [STATUS] [REASON-PHRASE].
sendAcknowledgement
in interface HttpResponse
sendAcknowledgement
in interface Response
IOException
- if an input/output error occurspublic void sendError(int status) throws IOException
sendError
in interface javax.servlet.http.HttpServletResponse
IOException
public void sendError(int status, String message) throws IOException
sendError
in interface javax.servlet.http.HttpServletResponse
IOException
public void sendRedirect(String location) throws IOException
sendRedirect
in interface javax.servlet.http.HttpServletResponse
IOException
public void setDateHeader(String name, long value)
setDateHeader
in interface javax.servlet.http.HttpServletResponse
public void setHeader(String name, String value)
setHeader
in interface javax.servlet.http.HttpServletResponse
public void setIntHeader(String name, int value)
setIntHeader
in interface javax.servlet.http.HttpServletResponse
public void setStatus(int status)
setStatus
in interface javax.servlet.http.HttpServletResponse
public void setStatus(int status, String message)
setStatus
in interface javax.servlet.http.HttpServletResponse
public void setDetailMessage(String msg)
Response
setDetailMessage
in interface Response
msg
- detail error messagepublic String getDetailMessage()
Response
getDetailMessage
in interface Response
Copyright © 2019. All rights reserved.