org.w3c.jigsaw.http
Class Reply

java.lang.Object
  extended by org.w3c.www.http.HttpMessage
      extended by org.w3c.www.http.HttpEntityMessage
          extended by org.w3c.www.http.HttpReplyMessage
              extended by org.w3c.jigsaw.http.Reply
All Implemented Interfaces:
java.lang.Cloneable, ReplyInterface, HTTP, MimeHeaderHolder
Direct Known Subclasses:
DAVReply

public class Reply
extends HttpReplyMessage
implements ReplyInterface


Field Summary
protected  java.lang.Boolean chunkable
          Should this reply be chunked ?
protected static java.lang.String chunked
           
protected static HttpTokenList CONNECTION
           
protected static HttpMimeType DEFAULT_TYPE
           
protected  ResourceFilter[] filters
           
protected  int infilters
           
protected  boolean is_proxy
          Is this reply a proxy reply.
protected  java.io.OutputStream output
           
 
Fields inherited from class org.w3c.www.http.HttpReplyMessage
H_ACCEPT_RANGES, H_AGE, H_AUTHENTICATION_INFO, H_LOCATION, H_PROXY_AUTHENTICATE, H_PUBLIC, H_RETRY_AFTER, H_SERVER, H_VARY, H_WARNING, H_WWW_AUTHENTICATE, reason, status
 
Fields inherited from class org.w3c.www.http.HttpEntityMessage
H_ALLOW, H_CONTENT_BASE, H_CONTENT_ENCODING, H_CONTENT_LANGUAGE, H_CONTENT_LENGTH, H_CONTENT_LOCATION, H_CONTENT_MD5, H_CONTENT_RANGE, H_CONTENT_TYPE, H_ETAG, H_EXPIRES, H_LAST_MODIFIED
 
Fields inherited from class org.w3c.www.http.HttpMessage
descriptors, EMIT_ALL, EMIT_BODY, EMIT_FOOTERS, EMIT_HEADERS, emitdate, factory, H_CACHE_CONTROL, H_CMAN_EXT, H_CONNECTION, H_COOKIE, H_COPT_EXT, H_DATE, H_MAN_EXT, H_OPT_EXT, H_PRAGMA, H_PROTOCOL, H_PROTOCOL_INFO, H_PROTOCOL_QUERY, H_PROTOCOL_REQUEST, H_PROXY_CONNECTION, H_SET_COOKIE, H_TRAILER, H_TRANSFER_ENCODING, H_UPGRADE, H_VIA, headers, major, MAX_HEADERS, minor, state, values
 
Fields inherited from interface org.w3c.www.http.HTTP
ACCEPTED, BAD_GATEWAY, BAD_REQUEST, byteArrayVersion, CONFLICT, CONNECT, CONTINUE, CREATED, DELETE, DONE, EXPECTATION_FAILED, FORBIDDEN, FOUND, GATEWAY_TIMEOUT, GET, GONE, HEAD, HTTP_100_CONTINUE, HTTP_VERSION_NOT_SUPPORTED, INTERNAL_SERVER_ERROR, LENGTH_REQUIRED, major_number, minor_number, MOVED_PERMANENTLY, msg_100, msg_200, msg_300, msg_400, msg_500, MULTIPLE_CHOICE, NO_CONTENT, NOHEADER, NON_AUTHORITATIVE_INFORMATION, NOT_ACCEPTABLE, NOT_ALLOWED, NOT_EXTENDED, NOT_FOUND, NOT_IMPLEMENTED, NOT_MODIFIED, OK, OPTIONS, PARTIAL_CONTENT, PAYMENT_REQUIRED, POST, PRECONDITION_FAILED, PROXY_AUTH_REQUIRED, PUT, REQUEST_ENTITY_TOO_LARGE, REQUEST_TIMEOUT, REQUEST_URI_TOO_LONG, REQUESTED_RANGE_NOT_SATISFIABLE, RESET_CONTENT, SEE_OTHER, SERVICE_UNAVAILABLE, SWITCHING, TEMPORARY_REDIRECT, TRACE, UNAUTHORIZED, UNSUPPORTED_MEDIA_TYPE, USE_PROXY
 
Constructor Summary
Reply(Client client)
          Create a new Reply instance for the given client.
Reply(Client client, Request request, short major, short minor, int status)
          Create a new reply for the given client.
 
Method Summary
 boolean canChunkTransfer()
           
 void dump(java.io.OutputStream out)
           
 void emit(java.io.OutputStream out, int what)
           
 MimeType getContentType()
          Get the entity MIME type.
 java.io.FileDescriptor getInputFileDescriptor()
          Deprecated.  
 java.io.OutputStream getOutputStream()
          Get that reply output stream.
 java.io.OutputStream getOutputStream(boolean doEmit)
          Get the reply output stream.
 boolean hasContentLength()
           
 boolean hasContentType()
           
 boolean hasStream()
           
 boolean isDynamic()
          is is dynamic or not?
 boolean keepProxyConnection()
           
 java.io.InputStream openStream()
          Open this reply body stream.
 void setContent(java.lang.String msg)
          Set this reply content.
 void setContent(java.lang.String msg, java.lang.String encoding)
          Set this reply content.
 void setDynamic(boolean dyn)
          set the reply to be a reply for dynamic content
protected  void setFilters(ResourceFilter[] filters, int infilters)
           
 void setKeepAlive(java.lang.String value)
           
 void setKeepConnection(boolean onoff)
           
 void setProxy(boolean onoff)
          Mark this reply as being a proxy reply.
 void setProxyConnection(java.lang.String value)
           
 void setStatus(java.lang.Integer status)
           
 void setStream(HtmlGenerator g)
          Sets the reply stream to the given HtmlGenerator stream.
 void setStream(java.io.InputStream is)
           
 void setStream(java.io.InputStream is, boolean closeOld)
           
 boolean tryKeepConnection()
           
 
Methods inherited from class org.w3c.www.http.HttpReplyMessage
addAuthenticationInfo, addWarning, checkMustRevalidate, checkProxyRevalidate, checkPublic, getAcceptRanges, getAge, getAuthenticationInfo, getLocation, getPrivate, getProxyAuthenticate, getPublic, getReason, getServer, getStandardReason, getStatus, getVary, getWarning, getWWWAuthenticate, notifyBeginParsing, setAcceptRanges, setAge, setAuthenticationInfo, setLocation, setLocation, setMustRevalidate, setProxyAuthenticate, setProxyRevalidate, setPublic, setPublic, setReason, setRetryAfter, setRetryAfter, setServer, setStatus, setVary, setWarning, setWWWAuthenticate, startEmit
 
Methods inherited from class org.w3c.www.http.HttpEntityMessage
addContentEncoding, getAllow, getContentBase, getContentEncoding, getContentLanguage, getContentLength, getContentLocation, getContentMD5, getContentRange, getETag, getExpires, getLastModified, hasContentRange, setAllow, setContentBase, setContentEncoding, setContentLanguage, setContentLength, setContentLocation, setContentMD5, setContentType, setETag, setExpires, setLastModified
 
Methods inherited from class org.w3c.www.http.HttpMessage
addConnection, addNoCache, addPragma, addProxyConnection, addTransferEncoding, addVia, checkNoStore, checkOnlyIfCached, delState, emit, emitHeaders, endEmit, enumerateHeaderDescriptions, enumerateHeaderDescriptions, generateExtNamespace, getCacheControl, getClone, getCManExtHeader, getConnection, getCookie, getCOptExtHeader, getDate, getDeeperClone, getEmitDate, getExtensionHeaders, getExtHeader, getExtList, getHeaderValue, getHeaderValue, getHeaderValue, getHeaderValue, getHttpCManExtDecl, getHttpCOptExtDecl, getHttpManExtDecl, getHttpOptExtDecl, getMajorVersion, getManExtHeader, getMaxAge, getMinorVersion, getNoCache, getOptExtHeader, getPragma, getProtocol, getProtocolInfo, getProtocolQuery, getProtocolRequest, getProxyConnection, getSetCookie, getSMaxAge, getState, getStateNames, getTrailer, getTransferEncoding, getUpgrade, getValue, getValue, getVersion, getVia, hasConnection, hasHeader, hasHeader, hasPragma, hasProxyConnection, hasState, hasTransferEncoding, notifyEndParsing, notifyHeader, registerExtHeader, registerHeader, registerHeader, removeHeader, removeHeader, setCacheControl, setConnection, setCookie, setDate, setEnd2EndExtensionAcknowledgmentHeader, setExtensionHeader, setHeaderValue, setHeaderValue, setHeaderValue, setHopByHopExtensionAcknowledgmentHeader, setHttpCManExtDecl, setHttpCOptExtDecl, setHttpExtDecl, setHttpManExtDecl, setHttpOptExtDecl, setMaxAge, setNamespaces, setNoCache, setNoCache, setNoStore, setOnlyIfCached, setPragma, setProtocol, setProtocolInfo, setProtocolQuery, setProtocolRequest, setProxyConnection, setSetCookie, setSMaxAge, setState, setTrailer, setTransferEncoding, setUpgrade, setValue, setVia
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_TYPE

protected static HttpMimeType DEFAULT_TYPE

CONNECTION

protected static HttpTokenList CONNECTION

is_proxy

protected boolean is_proxy
Is this reply a proxy reply.


filters

protected ResourceFilter[] filters

infilters

protected int infilters

output

protected java.io.OutputStream output

chunkable

protected java.lang.Boolean chunkable
Should this reply be chunked ?


chunked

protected static java.lang.String chunked
Constructor Detail

Reply

public Reply(Client client)
Create a new Reply instance for the given client.

Parameters:
client - The client to who this reply is directed.

Reply

public Reply(Client client,
             Request request,
             short major,
             short minor,
             int status)
Create a new reply for the given client.

Parameters:
client - The client ot who the reply is directed.
Method Detail

setDynamic

public void setDynamic(boolean dyn)
set the reply to be a reply for dynamic content

Parameters:
a - boolean, true if the reply is generated by a dynamic

isDynamic

public boolean isDynamic()
is is dynamic or not?


setStatus

public void setStatus(java.lang.Integer status)

hasContentLength

public boolean hasContentLength()

hasContentType

public boolean hasContentType()

setKeepAlive

public void setKeepAlive(java.lang.String value)

setProxyConnection

public void setProxyConnection(java.lang.String value)

keepProxyConnection

public boolean keepProxyConnection()

getInputFileDescriptor

public java.io.FileDescriptor getInputFileDescriptor()
Deprecated. 


setKeepConnection

public void setKeepConnection(boolean onoff)

tryKeepConnection

public boolean tryKeepConnection()

setProxy

public void setProxy(boolean onoff)
Mark this reply as being a proxy reply.


setStream

public void setStream(HtmlGenerator g)
Sets the reply stream to the given HtmlGenerator stream.

Parameters:
g - The HtmlGenerator whose output is to be used as the reply body.

hasStream

public boolean hasStream()

openStream

public java.io.InputStream openStream()
Open this reply body stream. This is used to send the reply body back to the client.

Returns:
An InputStream containing the reply body, which is dumped back to the client.

setStream

public void setStream(java.io.InputStream is)

setStream

public void setStream(java.io.InputStream is,
                      boolean closeOld)

setFilters

protected void setFilters(ResourceFilter[] filters,
                          int infilters)

getOutputStream

public java.io.OutputStream getOutputStream(boolean doEmit)
                                     throws java.io.IOException
Get the reply output stream.

Parameters:
doEmit - Emit that reply before giving out the output stream.
Returns:
An OutputStream instance.
Throws:
java.io.IOException - If the output stream could not get opened.

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
Get that reply output stream. The reply is first emitted to the stream, and the opened stream is returned back to the caller.

Returns:
An OutputStream instance.
Throws:
java.io.IOException - If the output stream could not get opened.

canChunkTransfer

public boolean canChunkTransfer()

setContent

public void setContent(java.lang.String msg,
                       java.lang.String encoding)
Set this reply content. This method allows to set the reply content to a simple String instance.

Parameters:
msg - The reply content.
encoding, - the encoding of the reply

emit

public void emit(java.io.OutputStream out,
                 int what)
          throws java.io.IOException
Overrides:
emit in class HttpMessage
Parameters:
out - The output stream to emit the message to.
what - (fixme doc)
Throws:
java.io.IOException - If the message couldn't be emited to the given stream, due to IO errors.

dump

public void dump(java.io.OutputStream out)
Overrides:
dump in class HttpReplyMessage

setContent

public void setContent(java.lang.String msg)
Set this reply content. This method allows to set the reply content to a simple String instance. encoding will be by default "ISO8859_1"

Specified by:
setContent in interface ReplyInterface
Parameters:
msg - The reply content.

getContentType

public MimeType getContentType()
Get the entity MIME type.

Overrides:
getContentType in class HttpEntityMessage
Returns:
An HttpMimeType object describing the entity's type, or null if udefined.