Interface Content.Sink

All Known Implementing Classes:
AsyncContent
Enclosing class:
Content

public static interface Content.Sink

A content sink that writes the content to its implementation (a socket, a file, etc.).

  • Method Details

    • asOutputStream

      static OutputStream asOutputStream(Content.Sink sink)

      Wraps the given content sink with an OutputStream.

      Parameters:
      sink - the sink to write to
      Returns:
      an OutputStream that writes to the content sink
    • asSubscriber

      static Flow.Subscriber<Content.Chunk> asSubscriber(Content.Sink sink, org.eclipse.jetty.util.Callback callback)

      Wraps the given content sink with a Flow.Subscriber.

      Parameters:
      sink - the sink to write to
      callback - the callback to notify when the Subscriber is complete
      Returns:
      a Subscriber that writes to the content sink
    • write

      static void write(Content.Sink sink, boolean last, ByteBuffer byteBuffer) throws IOException
      Parameters:
      sink - the sink to write to
      last - whether the ByteBuffers are the last to write
      byteBuffer - the ByteBuffers to write
      Throws:
      IOException - if the write operation fails
    • write

      static void write(Content.Sink sink, boolean last, String utf8Content, org.eclipse.jetty.util.Callback callback)

      Writes the given String, converting it to UTF-8 bytes, notifying the Callback when the write is complete.

      Parameters:
      last - whether the String is the last to write
      utf8Content - the String to write
      callback - the callback to notify when the write operation is complete. Implementations have the same guarantees for invocation of this callback as for write(boolean, ByteBuffer, Callback).
    • write

      void write(boolean last, ByteBuffer byteBuffer, org.eclipse.jetty.util.Callback callback)

      Writes the given ByteBuffer, notifying the Callback when the write is complete.

      Implementations guarantee that calls to this method are safely reentrant so that stack overflows are avoided in the case of mutual recursion between the execution of the Callback and a call to this method.

      Parameters:
      last - whether the ByteBuffer is the last to write
      byteBuffer - the ByteBuffer to write
      callback - the callback to notify when the write operation is complete