public abstract class AbstractGenerator extends Object implements Generator
| Modifier and Type | Field and Description |
|---|---|
protected Buffer |
_buffer |
protected Buffers |
_buffers |
protected Buffer |
_content |
protected long |
_contentLength |
protected long |
_contentWritten |
protected Buffer |
_date |
protected EndPoint |
_endp |
protected boolean |
_head |
protected Buffer |
_header |
protected boolean |
_last |
protected Buffer |
_method |
protected boolean |
_noContent |
protected Boolean |
_persistent |
protected Buffer |
_reason |
protected int |
_state |
protected int |
_status |
protected String |
_uri |
protected int |
_version |
static byte[] |
NO_BYTES |
static int |
STATE_CONTENT |
static int |
STATE_END |
static int |
STATE_FLUSHING |
static int |
STATE_HEADER |
| Constructor and Description |
|---|
AbstractGenerator(Buffers buffers,
EndPoint io)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
blockForOutput(long maxIdleTime) |
void |
complete()
Complete the message.
|
abstract void |
completeHeader(HttpFields fields,
boolean allContentAdded) |
void |
completeUncheckedAddContent() |
void |
flush(long maxIdleTime) |
abstract int |
flushBuffer() |
int |
getContentBufferSize() |
long |
getContentWritten() |
boolean |
getSendServerVersion() |
int |
getState() |
Buffer |
getUncheckedBuffer() |
int |
getVersion() |
void |
increaseContentBufferSize(int contentBufferSize) |
boolean |
isAllContentWritten() |
boolean |
isBufferFull() |
boolean |
isCommitted() |
boolean |
isComplete() |
boolean |
isHead() |
boolean |
isIdle() |
boolean |
isOpen() |
boolean |
isPersistent() |
abstract boolean |
isRequest() |
abstract boolean |
isResponse() |
boolean |
isState(int state) |
boolean |
isWritten() |
abstract int |
prepareUncheckedAddContent()
Prepare buffer for unchecked writes.
|
void |
reset() |
void |
resetBuffer() |
void |
returnBuffers() |
void |
sendError(int code,
String reason,
String content,
boolean close)
Utility method to send an error response.
|
void |
setContentLength(long value) |
void |
setDate(Buffer timeStampBuffer) |
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, waitaddContentpublic static final int STATE_HEADER
public static final int STATE_CONTENT
public static final int STATE_FLUSHING
public static final int STATE_END
public static final byte[] NO_BYTES
protected final Buffers _buffers
protected final EndPoint _endp
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 _persistent
protected Buffer _header
protected Buffer _buffer
protected Buffer _content
protected Buffer _date
public abstract boolean isRequest()
public abstract boolean isResponse()
public boolean isOpen()
public void returnBuffers()
returnBuffers in interface Generatorpublic 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 setDate(Buffer timeStampBuffer)
setDate in interface GeneratorGenerator.setDate(org.eclipse.jetty.io.Buffer)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.public abstract int prepareUncheckedAddContent()
throws IOException
IOExceptionpublic void completeUncheckedAddContent()
public boolean isBufferFull()
isBufferFull in interface Generatorpublic boolean isAllContentWritten()
isAllContentWritten 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 int flushBuffer()
throws IOException
flushBuffer in interface GeneratorIOExceptionpublic void flush(long maxIdleTime)
throws IOException
IOExceptionpublic void sendError(int code,
String reason,
String content,
boolean close)
throws IOException
sendError in interface Generatorcode - The error codereason - The error reasoncontent - Contents of the error pageclose - True if the connection should be closedIOException - if there is a problem flushing the responsepublic long getContentWritten()
getContentWritten in interface Generatorpublic void blockForOutput(long maxIdleTime)
throws IOException
IOExceptionCopyright © 1995-2015 Mort Bay Consulting. All Rights Reserved.