Class HttpExchangeWriter

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public final class HttpExchangeWriter
    extends java.lang.Object
    implements java.io.Closeable
    Writer of HTTP exchanges in the HTTP Types JSON Lines format.

    Output written using this writer can be read back using a HttpExchangeReader.

    • Constructor Summary

      Constructors 
      Constructor Description
      HttpExchangeWriter​(@NotNull java.io.OutputStream out)
      Creates a HTTP exchange writer that uses the specified output stream.
      HttpExchangeWriter​(@NotNull java.io.Writer out)
      Creates a HTTP exchange writer that uses the specified output writer.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      void write​(@NotNull HttpExchange exchange)
      Writes a HTTP exchange as a single JSON formatted line.
      void writeAll​(@NotNull java.util.Collection<HttpExchange> exchanges)
      Writes multiple HTTP Exchanges, each formatted in JSON format on a single line.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • HttpExchangeWriter

        public HttpExchangeWriter​(@NotNull
                                  @NotNull java.io.OutputStream out)
        Creates a HTTP exchange writer that uses the specified output stream.
        Parameters:
        out - Output where to write the serialized HTTP exchanges
      • HttpExchangeWriter

        public HttpExchangeWriter​(@NotNull
                                  @NotNull java.io.Writer out)
        Creates a HTTP exchange writer that uses the specified output writer.
        Parameters:
        out - Output where to write the serialized HTTP exchanges
    • Method Detail

      • write

        public void write​(@NotNull
                          @NotNull HttpExchange exchange)
        Writes a HTTP exchange as a single JSON formatted line.
        Parameters:
        exchange - The HTTP exchange to write
        See Also:
        writeAll(Collection)
      • writeAll

        public void writeAll​(@NotNull
                             @NotNull java.util.Collection<HttpExchange> exchanges)
        Writes multiple HTTP Exchanges, each formatted in JSON format on a single line.
        Parameters:
        exchanges - The HTTP exchanges to write
        See Also:
        write(HttpExchange)
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException