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, wait
addContent
public 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 Generator
public void resetBuffer()
resetBuffer
in interface Generator
public int getContentBufferSize()
getContentBufferSize
in interface Generator
public void increaseContentBufferSize(int contentBufferSize)
increaseContentBufferSize
in interface Generator
contentBufferSize
- The contentBufferSize to set.public Buffer getUncheckedBuffer()
public boolean getSendServerVersion()
public void setSendServerVersion(boolean sendServerVersion)
setSendServerVersion
in interface Generator
public int getState()
public boolean isState(int state)
public boolean isComplete()
isComplete
in interface Generator
public boolean isCommitted()
isCommitted
in interface Generator
public boolean isHead()
public void setContentLength(long value)
setContentLength
in interface Generator
public void setHead(boolean head)
public boolean isPersistent()
isPersistent
in interface Generator
false
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 Generator
public void setVersion(int version)
setVersion
in interface Generator
version
- 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 Generator
Generator.setDate(org.eclipse.jetty.io.Buffer)
public void setRequest(String method, String uri)
setRequest
in interface Generator
public void setResponse(int status, String reason)
setResponse
in interface Generator
status
- The status code to send.reason
- the status message to send.public abstract int prepareUncheckedAddContent() throws IOException
IOException
public void completeUncheckedAddContent()
public boolean isBufferFull()
isBufferFull
in interface Generator
public boolean isAllContentWritten()
isAllContentWritten
in interface Generator
public abstract void completeHeader(HttpFields fields, boolean allContentAdded) throws IOException
completeHeader
in interface Generator
IOException
public void complete() throws IOException
complete
in interface Generator
IOException
public abstract int flushBuffer() throws IOException
flushBuffer
in interface Generator
IOException
public void flush(long maxIdleTime) throws IOException
IOException
public void sendError(int code, String reason, String content, boolean close) throws IOException
sendError
in interface Generator
code
- 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 Generator
public void blockForOutput(long maxIdleTime) throws IOException
IOException
Copyright © 1995-2013 Mort Bay Consulting. All Rights Reserved.