public abstract class AbstractGenerator extends Object implements Generator
| Modifier and Type | Class and Description |
|---|---|
static class |
AbstractGenerator.Output
Output.
|
static class |
AbstractGenerator.OutputWriter
OutputWriter.
|
| Modifier and Type | Field and Description |
|---|---|
protected Buffer |
_buffer |
protected Buffers |
_buffers |
protected boolean |
_close |
protected Buffer |
_content |
protected int |
_contentBufferSize |
protected long |
_contentLength |
protected long |
_contentWritten |
protected EndPoint |
_endp |
protected boolean |
_head |
protected Buffer |
_header |
protected int |
_headerBufferSize |
protected boolean |
_last |
protected Buffer |
_method |
protected boolean |
_noContent |
protected Buffer |
_reason |
protected int |
_state |
protected int |
_status |
protected String |
_uri |
protected int |
_version |
static int |
STATE_CONTENT |
static int |
STATE_END |
static int |
STATE_FLUSHING |
static int |
STATE_HEADER |
| Constructor and Description |
|---|
AbstractGenerator(Buffers buffers,
EndPoint io,
int headerBufferSize,
int contentBufferSize)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
complete()
Complete the message.
|
abstract void |
completeHeader(HttpFields fields,
boolean allContentAdded) |
abstract long |
flush() |
int |
getContentBufferSize() |
long |
getContentWritten() |
static String |
getReason(int code) |
protected static Buffer |
getReasonBuffer(int code) |
boolean |
getSendServerVersion() |
int |
getState() |
Buffer |
getUncheckedBuffer() |
int |
getVersion() |
void |
increaseContentBufferSize(int contentBufferSize) |
boolean |
isBufferFull() |
boolean |
isCommitted() |
boolean |
isComplete() |
boolean |
isContentWritten() |
boolean |
isHead() |
boolean |
isIdle() |
boolean |
isPersistent() |
boolean |
isState(int state) |
protected abstract int |
prepareUncheckedAddContent()
Prepare buffer for unchecked writes.
|
void |
reset(boolean returnBuffers) |
void |
resetBuffer() |
void |
sendError(int code,
String reason,
String content,
boolean close)
Utility method to send an error response.
|
void |
setContentLength(long value) |
void |
setHead(boolean head) |
void |
setPersistent(boolean persistent) |
void |
setRequest(String method,
String uri) |
void |
setResponse(int status,
String reason) |
void |
setSendServerVersion(boolean sendServerVersion) |
void |
setVersion(int version) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddContent, addContentpublic static final int STATE_HEADER
public static final int STATE_CONTENT
public static final int STATE_FLUSHING
public static final int STATE_END
protected int _state
protected int _status
protected int _version
protected Buffer _reason
protected Buffer _method
protected String _uri
protected long _contentWritten
protected long _contentLength
protected boolean _last
protected boolean _head
protected boolean _noContent
protected boolean _close
protected Buffers _buffers
protected EndPoint _endp
protected int _headerBufferSize
protected int _contentBufferSize
protected Buffer _header
protected Buffer _buffer
protected Buffer _content
protected static Buffer getReasonBuffer(int code)
public static String getReason(int code)
public void resetBuffer()
resetBuffer in interface Generatorpublic int getContentBufferSize()
getContentBufferSize in interface Generatorpublic void increaseContentBufferSize(int contentBufferSize)
increaseContentBufferSize in interface GeneratorcontentBufferSize - The contentBufferSize to set.public Buffer getUncheckedBuffer()
public boolean getSendServerVersion()
public void setSendServerVersion(boolean sendServerVersion)
setSendServerVersion in interface Generatorpublic int getState()
public boolean isState(int state)
public boolean isComplete()
isComplete in interface Generatorpublic boolean isCommitted()
isCommitted in interface Generatorpublic boolean isHead()
public void setContentLength(long value)
setContentLength in interface Generatorpublic void setHead(boolean head)
public boolean isPersistent()
isPersistent in interface Generatorfalse if the connection should be closed after a request has been read,
true if it should be used for additional requests.public void setPersistent(boolean persistent)
setPersistent in interface Generatorpublic void setVersion(int version)
setVersion in interface Generatorversion - The version of the client the response is being sent to (NB. Not the version
in the response, which is the version of the server).public int getVersion()
public void setRequest(String method, String uri)
setRequest in interface Generatorpublic void setResponse(int status,
String reason)
setResponse in interface Generatorstatus - The status code to send.reason - the status message to send.protected abstract int prepareUncheckedAddContent()
throws IOException
IOExceptionpublic boolean isBufferFull()
isBufferFull in interface Generatorpublic boolean isContentWritten()
isContentWritten in interface Generatorpublic abstract void completeHeader(HttpFields fields, boolean allContentAdded) throws IOException
completeHeader in interface GeneratorIOExceptionpublic void complete()
throws IOException
complete in interface GeneratorIOExceptionpublic abstract long flush()
throws IOException
flush in interface GeneratorIOExceptionpublic void sendError(int code,
String reason,
String content,
boolean close)
throws IOException
sendError in interface Generatorcode - reason - content - close - IOExceptionpublic long getContentWritten()
getContentWritten in interface GeneratorCopyright © 2009 Mortbay Consulting Pty. Ltd. All Rights Reserved.