|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.grizzly.tcp.http11.GrizzlyResponse
public class GrizzlyResponse
Wrapper object for the Coyote response.
Field Summary | |
---|---|
protected boolean |
appCommitted
The application commit flag. |
protected ArrayList |
cookies
The set of Cookies associated with this Response. |
protected boolean |
error
The error flag. |
protected SimpleDateFormat |
format
The date format we will use for creating date headers. |
protected boolean |
included
The included flag. |
protected static String |
info
Descriptive information about this Response implementation. |
protected GrizzlyOutputBuffer |
outputBuffer
The associated output buffer. |
protected GrizzlyOutputStream |
outputStream
The associated output stream. |
protected CharChunk |
redirectURLCC
Recyclable buffer to hold the redirect URL. |
protected GrizzlyRequest |
request
The request with which this response is associated. |
protected Response |
response
Coyote response. |
protected static StringManager |
sm
The string manager for this package. |
protected UEncoder |
urlEncoder
URL encoder. |
protected boolean |
usingOutputStream
Using output stream flag. |
protected boolean |
usingWriter
Using writer flag. |
protected GrizzlyWriter |
writer
The associated writer. |
Constructor Summary | |
---|---|
GrizzlyResponse()
|
|
GrizzlyResponse(boolean chunkingDisabled,
boolean cacheEnabled)
|
Method Summary | |
---|---|
void |
addCookie(Cookie cookie)
Add the specified Cookie to those that will be included with this Response. |
void |
addDateHeader(String name,
long value)
Add the specified date header to the specified value. |
void |
addHeader(String name,
String value)
Add the specified header to the specified value. |
void |
addIntHeader(String name,
int value)
Add the specified integer header to the specified value. |
boolean |
containsHeader(String name)
Has the specified header been set already in this response? |
GrizzlyOutputStream |
createOutputStream()
Create and return a ServletOutputStream to write the content associated with this Response. |
void |
enableCache(boolean cacheEnabled)
Enable/disable the cache |
String |
encodeURL(String url)
Encode the session identifier associated with this response into the specified URL, if necessary. |
void |
finishResponse()
Perform whatever actions are required to flush and close the output stream or writer, in a single operation. |
void |
flushBuffer()
Flush the buffer and commit this response. |
int |
getBufferSize()
Return the actual buffer size used for this Response. |
String |
getCharacterEncoding()
Return the character encoding used for this Response. |
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. |
Cookie[] |
getCookies()
Return an array of all cookies set for this response, or a zero-length array if no cookies have been set. |
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. |
String[] |
getHeaderNames()
Return an array of all the header names set for this response, or a zero-length array if no headers have been set. |
String[] |
getHeaderValues(String name)
Return an array of all the header values associated with the specified header name, or an zero-length array if there are no such header values. |
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()
Return the Locale assigned to this response. |
String |
getMessage()
Return the error message that was set with sendError()
for this Response. |
GrizzlyOutputBuffer |
getOutputBuffer()
Return the underlying OutputBuffer |
GrizzlyOutputStream |
getOutputStream()
Return the servlet output stream associated with this Response. |
PrintWriter |
getReporter()
Return a PrintWriter that can be used to render error messages, regardless of whether a stream or writer has already been acquired. |
GrizzlyRequest |
getRequest()
Return the Request with which this Response is associated. |
Response |
getResponse()
Get the Coyote response. |
int |
getStatus()
Return the HTTP status code associated with this Response. |
OutputStream |
getStream()
Return the output stream associated with this Response. |
PrintWriter |
getWriter()
Return the writer associated with this Response. |
boolean |
isAppCommitted()
Application commit flag accessor. |
boolean |
isCacheEnabled()
Is the file cache enabled? |
boolean |
isCommitted()
Has the output of this response already been committed? |
protected boolean |
isEncodeable(String location)
Return true if the specified URL should be encoded with
a session identifier. |
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()
Clear any content written to the buffer. |
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 |
sendAcknowledgement()
Send an acknowledgment of a request. |
void |
sendError(int status)
Send an error response with the specified status and a default message. |
void |
sendError(int status,
String message)
Send an error response with the specified status and message. |
void |
sendRedirect(String location)
Send a temporary redirect to the specified redirect location URL. |
void |
setAppCommitted(boolean appCommitted)
Set the application commit flag. |
void |
setBufferSize(int size)
Set the buffer size to be used for this Response. |
void |
setCharacterEncoding(String charset)
|
void |
setContentLength(int length)
Set the content length (in bytes) for this Response. |
void |
setContentLengthLong(long length)
Set the content length (in bytes) for this Response. |
void |
setContentType(String type)
Set the content type for this Response. |
void |
setDateHeader(String name,
long value)
Set the specified date header to the specified value. |
void |
setDetailMessage(String message)
Sets detail error message. |
void |
setError()
Set the error flag. |
void |
setHeader(String name,
String value)
Set the specified header to the specified value. |
void |
setIncluded(boolean included)
Set the "processing inside an include" flag. |
void |
setIntHeader(String name,
int value)
Set the specified integer header to the specified value. |
void |
setLocale(Locale locale)
Set the Locale that is appropriate for this response, including setting the appropriate character encoding. |
void |
setRequest(GrizzlyRequest request)
Set the Request with which this Response is associated. |
void |
setResponse(Response response)
Set the Coyote response. |
void |
setStatus(int status)
Set the HTTP status to be returned with this response. |
void |
setStatus(int status,
String message)
Deprecated. As of Version 2.1 of the Java Servlet API, this method has been deprecated due to the ambiguous meaning of the message parameter. |
void |
setStream(OutputStream stream)
Set the output stream associated with this Response. |
void |
setSuspended(boolean suspended)
Set the suspended flag. |
protected String |
toAbsolute(String location)
Convert (if necessary) and return the absolute URL that represents the resource referenced by this possibly relative URL. |
protected String |
toEncoded(String url,
String sessionId)
Return the specified URL with the specified session identifier suitably encoded. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected SimpleDateFormat format
protected static final String info
protected static StringManager sm
protected GrizzlyRequest request
protected Response response
protected GrizzlyOutputBuffer outputBuffer
protected GrizzlyOutputStream outputStream
protected GrizzlyWriter writer
protected boolean appCommitted
protected boolean included
protected boolean error
protected ArrayList cookies
protected boolean usingOutputStream
protected boolean usingWriter
protected UEncoder urlEncoder
protected CharChunk redirectURLCC
Constructor Detail |
---|
public GrizzlyResponse()
public GrizzlyResponse(boolean chunkingDisabled, boolean cacheEnabled)
Method Detail |
---|
public GrizzlyRequest getRequest()
public void setRequest(GrizzlyRequest request)
request
- The new associated requestpublic void setResponse(Response response)
response
- The Coyote responsepublic Response getResponse()
public void recycle()
public String encodeURL(String url)
url
- URL to be encodedprotected boolean isEncodeable(String location)
true
if the specified URL should be encoded with
a session identifier. This will be true if all of the following
conditions are met:
location
- Absolute URL to be validatedpublic int getContentCount()
public void setAppCommitted(boolean appCommitted)
appCommitted
- The new application committed flag valuepublic boolean isAppCommitted()
public boolean getIncluded()
public void setIncluded(boolean included)
included
- true
if we are currently inside a
RequestDispatcher.include(), else false
public String getInfo()
<description>/<version>
.
public OutputStream getStream()
public void setStream(OutputStream stream)
stream
- The new output streampublic void setSuspended(boolean suspended)
suspended
- The new suspended flag valuepublic boolean isSuspended()
public void setError()
public boolean isError()
public void setDetailMessage(String message)
message
- detail error messagepublic String getDetailMessage()
public GrizzlyOutputStream createOutputStream() throws IOException
IOException
- if an input/output error occurspublic void finishResponse() throws IOException
IOException
- if an input/output error occurspublic int getContentLength()
public String getContentType()
null
if no content type was set.
public PrintWriter getReporter() throws IOException
IOException
- if an input/output error occurspublic void flushBuffer() throws IOException
IOException
- if an input/output error occurspublic int getBufferSize()
public String getCharacterEncoding()
public GrizzlyOutputStream getOutputStream() throws IOException
IllegalStateException
- if getWriter
has
already been called for this response
IOException
- if an input/output error occurspublic Locale getLocale()
public PrintWriter getWriter() throws IOException
IllegalStateException
- if getOutputStream
has
already been called for this response
IOException
- if an input/output error occurspublic boolean isCommitted()
public void reset()
IllegalStateException
- if this response has already
been committedpublic void resetBuffer()
IllegalStateException
- if the response has already
been committedpublic void setBufferSize(int size)
size
- The new buffer size
IllegalStateException
- if this method is called after
output has been committed for this responsepublic void setContentLengthLong(long length)
length
- The new content lengthpublic void setContentLength(int length)
length
- The new content lengthpublic void setContentType(String type)
type
- The new content typepublic void setCharacterEncoding(String charset)
public void setLocale(Locale locale)
locale
- The new localepublic Cookie[] getCookies()
public String getHeader(String name)
null
if this
header has not been set. If more than one value was added for this
name, only the first is returned; use getHeaderValues() to retrieve all
of them.
name
- Header name to look uppublic String[] getHeaderNames()
public String[] getHeaderValues(String name)
name
- Header name to look uppublic String getMessage()
sendError()
for this Response.
public int getStatus()
public void reset(int status, String message)
IllegalStateException
- if this response has already been
committedpublic void addCookie(Cookie cookie)
cookie
- Cookie to be addedpublic void addDateHeader(String name, long value)
name
- Name of the header to setvalue
- Date value to be setpublic void addHeader(String name, String value)
name
- Name of the header to setvalue
- Value to be setpublic void addIntHeader(String name, int value)
name
- Name of the header to setvalue
- Integer value to be setpublic boolean containsHeader(String name)
name
- Name of the header to checkpublic void sendAcknowledgement() throws IOException
IOException
- if an input/output error occurspublic void sendError(int status) throws IOException
status
- HTTP status code to send
IllegalStateException
- if this response has
already been committed
IOException
- if an input/output error occurspublic void sendError(int status, String message) throws IOException
status
- HTTP status code to sendmessage
- Corresponding message to send
IllegalStateException
- if this response has
already been committed
IOException
- if an input/output error occurspublic void sendRedirect(String location) throws IOException
location
- Location URL to redirect to
IllegalStateException
- if this response has
already been committed
IOException
- if an input/output error occurspublic void setDateHeader(String name, long value)
name
- Name of the header to setvalue
- Date value to be setpublic void setHeader(String name, String value)
name
- Name of the header to setvalue
- Value to be setpublic void setIntHeader(String name, int value)
name
- Name of the header to setvalue
- Integer value to be setpublic void setStatus(int status)
status
- The new HTTP statuspublic void setStatus(int status, String message)
status
- The new HTTP statusmessage
- The associated text messageprotected String toAbsolute(String location)
location
- URL to be (possibly) converted and then returned
IllegalArgumentException
- if a MalformedURLException is
thrown when converting the relative URL to an absolute oneprotected String toEncoded(String url, String sessionId)
url
- URL to be encoded with the session idsessionId
- Session id to be included in the encoded URLpublic boolean isCacheEnabled()
public void enableCache(boolean cacheEnabled)
public GrizzlyOutputBuffer getOutputBuffer()
OutputBuffer
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |