org.eclipse.jetty.http

## Class AbstractGenerator

- java.lang.Object
- - org.eclipse.jetty.http.AbstractGenerator

- All Implemented Interfaces:
    Generator
  Direct Known Subclasses:
    Ajp13Generator, HttpGenerator, NestedGenerator

      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.

- - ### Field Summary

    Fields
    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`

    - ### Fields inherited from interface org.eclipse.jetty.http.Generator

      `LAST, MORE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractGenerator(Buffers buffers, EndPoint io)` Constructor.

  - ### Method Summary

    Methods
    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)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.eclipse.jetty.http.Generator

      `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

    - #### NO_BYTES

          public static final byte[] NO_BYTES

    - #### _buffers

          protected final Buffers _buffers

    - #### _endp

          protected final EndPoint _endp

    - #### _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

    - #### _persistent

          protected Boolean _persistent

    - #### _header

          protected Buffer _header

    - #### _buffer

          protected Buffer _buffer

    - #### _content

          protected Buffer _content

    - #### _date

          protected Buffer _date

  - ### Constructor Detail

    - #### AbstractGenerator

          public AbstractGenerator(Buffers buffers,
                           EndPoint io)

      Constructor.
      Parameters:
        `buffers` - buffer pool
        `io` - the end point

  - ### Method Detail

    - #### isRequest

          public abstract boolean isRequest()

    - #### isResponse

          public abstract boolean isResponse()

    - #### isOpen

          public boolean isOpen()

    - #### reset

          public void reset()

      Specified by:
        `reset` in interface `Generator`

    - #### returnBuffers

          public void returnBuffers()

      Specified by:
        `returnBuffers` 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)

      Specified by:
        `setPersistent` in interface `Generator`

    - #### 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()

    - #### setDate

          public void setDate(Buffer timeStampBuffer)

      Specified by:
        `setDate` in interface `Generator`
      See Also:
        `Generator.setDate(org.eclipse.jetty.io.Buffer)`

    - #### 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

          public 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`

    - #### completeUncheckedAddContent

          public void completeUncheckedAddContent()

    - #### isBufferFull

          public boolean isBufferFull()

      Specified by:
        `isBufferFull` in interface `Generator`

    - #### isWritten

          public boolean isWritten()

      Specified by:
        `isWritten` in interface `Generator`

    - #### isAllContentWritten

          public boolean isAllContentWritten()

      Specified by:
        `isAllContentWritten` in interface `Generator`

    - #### 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`

    - #### flushBuffer

          public abstract int flushBuffer()
                                   throws IOException

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

    - #### flush

          public void flush(long maxIdleTime)
                     throws IOException

      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` - The error code
        `reason` - The error reason
        `content` - Contents of the error page
        `close` - True if the connection should be closed
      Throws:
        `IOException` - if there is a problem flushing the response

    - #### getContentWritten

          public long getContentWritten()

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

    - #### blockForOutput

          public void blockForOutput(long maxIdleTime)
                              throws IOException

      Throws:
        `IOException`

Copyright © 1995-2013 Mort Bay Consulting. All Rights Reserved.