org.apache.hc.core5.http.impl.nio

## Class AbstractMessageWriter<T extends HttpMessage>

- java.lang.Object
- - org.apache.hc.core5.http.impl.nio.AbstractMessageWriter<T>

- Type Parameters:
    `T` - The type of `HttpMessage`.
  All Implemented Interfaces:
    NHttpMessageWriter<T>
  Direct Known Subclasses:
    DefaultHttpRequestWriter, DefaultHttpResponseWriter

      public abstract class AbstractMessageWriter<T extends HttpMessage>
      extends Object
      implements NHttpMessageWriter<T>

  Abstract `NHttpMessageWriter` that serves as a base for all message writer implementations.
  Since:
    4.0

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractMessageWriter(LineFormatter formatter)` Creates an instance of AbstractMessageWriter.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `reset()` Resets the writer.
    `void` | `write(T message, SessionOutputBuffer sessionBuffer)` Writes out the HTTP message head.
    `protected abstract void` | `writeHeadLine(T message, CharArrayBuffer buffer)` Writes out the first line of `HttpMessage`.

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

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

- - ### Constructor Detail

    - #### AbstractMessageWriter

          public AbstractMessageWriter(LineFormatter formatter)

      Creates an instance of AbstractMessageWriter.
      Parameters:
        `formatter` - the line formatter If `null` `BasicLineFormatter.INSTANCE` will be used.
      Since:
        4.3

  - ### Method Detail

    - #### reset

          public void reset()

      Description copied from interface: `NHttpMessageWriter`
      Resets the writer. The writer will be ready to start serializing another HTTP message.
      Specified by:
        `reset` in interface `NHttpMessageWriter<T extends HttpMessage>`

    - #### writeHeadLine

          protected abstract void writeHeadLine(T message,
                                                CharArrayBuffer buffer)
                                         throws IOException

      Writes out the first line of `HttpMessage`.
      Parameters:
        `message` - HTTP message.
      Throws:
        `IOException` - in case of an I/O error.

    - #### write

          public void write(T message,
                            SessionOutputBuffer sessionBuffer)
                     throws IOException,
                            HttpException

      Description copied from interface: `NHttpMessageWriter`
      Writes out the HTTP message head.
      Specified by:
        `write` in interface `NHttpMessageWriter<T extends HttpMessage>`
      Parameters:
        `message` - HTTP message.
        `sessionBuffer` - session output buffer.
      Throws:
        `IOException` - in case of an I/O error.
        `HttpException` - in case the HTTP message is malformed or violates the HTTP protocol.

Copyright © 2005–2021 The Apache Software Foundation. All rights reserved.