## org.apache.http.impl.io
Class AbstractMessageWriter<T extends HttpMessage>

    java.lang.Object
      org.apache.http.impl.io.AbstractMessageWriter<T>

All Implemented Interfaces:
  HttpMessageWriter<T>

Direct Known Subclasses:
  HttpRequestWriter, HttpResponseWriter

    @NotThreadSafe
    public abstract class AbstractMessageWriter<T extends HttpMessage>

extends Object
implements HttpMessageWriter<T>

Abstract base class for HTTP message writers that serialize output to an instance of `SessionOutputBuffer`.

Since:
  4.0

Field Summary
`protected CharArrayBuffer` `lineBuf`
`protected LineFormatter` `lineFormatter`
`protected SessionOutputBuffer` `sessionBuffer`

Constructor Summary
`AbstractMessageWriter(SessionOutputBuffer buffer, LineFormatter formatter, HttpParams params)` Creates an instance of AbstractMessageWriter.

Method Summary
`void` `write(T message)` Serializes an instance of `HttpMessage` to the underlying data sink.
`protected abstract void` `writeHeadLine(T message)` Subclasses must override this method to write out the first header line based on the `HttpMessage` passed as a parameter.

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

Field Detail

### sessionBuffer

    protected final SessionOutputBuffer sessionBuffer

### lineBuf

    protected final CharArrayBuffer lineBuf

### lineFormatter

    protected final LineFormatter lineFormatter

Constructor Detail

### AbstractMessageWriter

    public AbstractMessageWriter(SessionOutputBuffer buffer,
                                 LineFormatter formatter,
                                 HttpParams params)

  Creates an instance of AbstractMessageWriter.

  Parameters:
    `buffer` - the session output buffer.
    `formatter` - the line formatter.
    `params` - HTTP parameters.

Method Detail

### writeHeadLine

    protected abstract void writeHeadLine(T message)
                                   throws IOException

  Subclasses must override this method to write out the first header line based on the `HttpMessage` passed as a parameter.

  Parameters:
    `message` - the message whose first line is to be written out.
  Throws:
    `IOException` - in case of an I/O error.

### write

    public void write(T message)
               throws IOException,
                      HttpException

  Description copied from interface: `HttpMessageWriter`
  Serializes an instance of `HttpMessage` to the underlying data sink.

  Specified by:
    `write` in interface `HttpMessageWriter<T extends HttpMessage>`
  Throws:
    `IOException` - in case of an I/O error
    `HttpException` - in case of HTTP protocol violation

Copyright © 2005-2013 The Apache Software Foundation. All Rights Reserved.