Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.mortbay.jetty
Class AbstractGenerator

    java.lang.Object
      org.mortbay.jetty.AbstractGenerator

All Implemented Interfaces:
  Generator

Direct Known Subclasses:
  Ajp13Generator, HttpGenerator

    public abstract class AbstractGenerator

extends Object
implements Generator

Abstract Generator. Builds HTTP Messages. Currently this class uses a system parameter "jetty.direct.writers" to control two optional writer to byte conversions. buffer.writers=true will probably be faster, but will consume more memory. This option is just for testing and tuning.

Author:
  gregw

Nested Class Summary
`static class` | `AbstractGenerator.Output` Output.
`static class` | `AbstractGenerator.OutputWriter` OutputWriter.

Field Summary
`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`

Fields inherited from interface org.mortbay.jetty.Generator
`LAST, MORE`

Constructor Summary
`AbstractGenerator(Buffers buffers, EndPoint io, int headerBufferSize, int contentBufferSize)` Constructor.

Method Summary
`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)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface org.mortbay.jetty.Generator
`addContent, addContent`

Field Detail

### STATE_HEADER

    public static final int STATE_HEADER

See Also:
  Constant Field Values

### STATE_CONTENT

    public static final int STATE_CONTENT

See Also:
  Constant Field Values

### STATE_FLUSHING

    public static final int STATE_FLUSHING

See Also:
  Constant Field Values

### STATE_END

    public static final int STATE_END

See Also:
  Constant Field Values

### _state

    protected int _state

### _status

    protected int _status

### _version

    protected int _version

### _reason

    protected Buffer _reason

### _method

    protected Buffer _method

### _uri

    protected String _uri

### _contentWritten

    protected long _contentWritten

### _contentLength

    protected long _contentLength

### _last

    protected boolean _last

### _head

    protected boolean _head

### _noContent

    protected boolean _noContent

### _close

    protected boolean _close

### _buffers

    protected Buffers _buffers

### _endp

    protected EndPoint _endp

### _headerBufferSize

    protected int _headerBufferSize

### _contentBufferSize

    protected int _contentBufferSize

### _header

    protected Buffer _header

### _buffer

    protected Buffer _buffer

### _content

    protected Buffer _content

Constructor Detail

### AbstractGenerator

    public AbstractGenerator(Buffers buffers,
                             EndPoint io,
                             int headerBufferSize,
                             int contentBufferSize)

  Constructor.

  Parameters:
    `buffers` - buffer pool
    `headerBufferSize` - Size of the buffer to allocate for HTTP header
    `contentBufferSize` - Size of the buffer to allocate for HTTP content

Method Detail

### getReasonBuffer

    protected static Buffer getReasonBuffer(int code)

### getReason

    public static String getReason(int code)

### reset

    public void reset(boolean returnBuffers)

  Specified by:
    `reset` in interface `Generator`

### resetBuffer

    public void resetBuffer()

  Specified by:
    `resetBuffer` in interface `Generator`

### getContentBufferSize

    public int getContentBufferSize()

  Specified by:
    `getContentBufferSize` in interface `Generator`
  Returns:
    Returns the contentBufferSize.

### increaseContentBufferSize

    public void increaseContentBufferSize(int contentBufferSize)

  Specified by:
    `increaseContentBufferSize` in interface `Generator`
  Parameters:
    `contentBufferSize` - The contentBufferSize to set.

### getUncheckedBuffer

    public Buffer getUncheckedBuffer()

### getSendServerVersion

    public boolean getSendServerVersion()

### setSendServerVersion

    public void setSendServerVersion(boolean sendServerVersion)

  Specified by:
    `setSendServerVersion` in interface `Generator`

### getState

    public int getState()

### isState

    public boolean isState(int state)

### isComplete

    public boolean isComplete()

  Specified by:
    `isComplete` in interface `Generator`

### isIdle

    public boolean isIdle()

  Specified by:
    `isIdle` in interface `Generator`

### isCommitted

    public boolean isCommitted()

  Specified by:
    `isCommitted` in interface `Generator`

### isHead

    public boolean isHead()

  Returns:
    Returns the head.

### setContentLength

    public void setContentLength(long value)

  Specified by:
    `setContentLength` in interface `Generator`

### setHead

    public void setHead(boolean head)

  Specified by:
    `setHead` in interface `Generator`
  Parameters:
    `head` - The head to set.

### isPersistent

    public boolean isPersistent()

  Specified by:
    `isPersistent` in interface `Generator`
  Returns:
    `false` if the connection should be closed after a request has been read, `true` if it should be used for additional requests.

### setPersistent

    public void setPersistent(boolean persistent)

### setVersion

    public void setVersion(int version)

  Specified by:
    `setVersion` in interface `Generator`
  Parameters:
    `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).

### getVersion

    public int getVersion()

### setRequest

    public void setRequest(String method,
                           String uri)

  Specified by:
    `setRequest` in interface `Generator`

### setResponse

    public void setResponse(int status,
                            String reason)

  Specified by:
    `setResponse` in interface `Generator`
  Parameters:
    `status` - The status code to send.
    `reason` - the status message to send.

### prepareUncheckedAddContent

    protected abstract int prepareUncheckedAddContent()
                                               throws IOException

  Prepare buffer for unchecked writes. Prepare the generator buffer to receive unchecked writes

  Returns:
    the available space in the buffer.
  Throws:
    `IOException`

### isBufferFull

    public boolean isBufferFull()

  Specified by:
    `isBufferFull` in interface `Generator`

### isContentWritten

    public boolean isContentWritten()

### completeHeader

    public abstract void completeHeader(HttpFields fields,
                                        boolean allContentAdded)
                                 throws IOException

  Specified by:
    `completeHeader` in interface `Generator`
  Throws:
    `IOException`

### complete

    public void complete()
                  throws IOException

  Complete the message.

  Specified by:
    `complete` in interface `Generator`
  Throws:
    `IOException`

### flush

    public abstract long flush()
                        throws IOException

  Specified by:
    `flush` in interface `Generator`
  Throws:
    `IOException`

### sendError

    public void sendError(int code,
                          String reason,
                          String content,
                          boolean close)
                   throws IOException

  Utility method to send an error response. If the builder is not committed, this call is equivalent to a setResponse, addcontent and complete call.

  Specified by:
    `sendError` in interface `Generator`
  Parameters:
    `code` -
    `reason` -
    `content` -
    `close` -
  Throws:
    `IOException`

### getContentWritten

    public long getContentWritten()

  Specified by:
    `getContentWritten` in interface `Generator`
  Returns:
    Returns the contentWritten.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2007 Mort Bay Consulting. All Rights Reserved.