Class Content

java.lang.Object
org.eclipse.jetty.io.Content

public class Content extends Object

Namespace class that contains the definitions of a content source, a content sink and a content chunk.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    A chunk of content indicating whether it is the last chunk.
    static interface 
    A content sink that writes the content to its implementation (a socket, a file, etc.).
    static interface 
    A source of content that can be read with a read/demand model.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    copy(Content.Source source, Content.Sink sink, Content.Chunk.Processor chunkProcessor, Callback callback)
    Copies the given content source to the given content sink, notifying the given callback when the copy is complete.
    static void
    copy(Content.Source source, Content.Sink sink, Callback callback)
    Copies the given content source to the given content sink, notifying the given callback when the copy is complete (either succeeded or failed).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • copy

      public static void copy(Content.Source source, Content.Sink sink, Callback callback)

      Copies the given content source to the given content sink, notifying the given callback when the copy is complete (either succeeded or failed).

      In case of failure chunks, the content source is failed.

      Parameters:
      source - the source to copy from
      sink - the sink to copy to
      callback - the callback to notify when the copy is complete
      See Also:
    • copy

      public static void copy(Content.Source source, Content.Sink sink, Content.Chunk.Processor chunkProcessor, Callback callback)

      Copies the given content source to the given content sink, notifying the given callback when the copy is complete.

      The optional chunkHandler parameter is a predicate whose code may inspect the chunk and handle it differently from how the implementation would handle it.

      If the predicate returns true, it means that the chunk is handled externally and its callback completed, or eventually completed.

      If the predicate returns false, it means that the chunk is not handled, its callback will not be completed, and the implementation will handle the chunk and its callback.

      In case of failure chunks not handled by any chunkHandler, the content source is failed if the failure chunk is last, else the failure is transient and is ignored.

      Parameters:
      source - the source to copy from
      sink - the sink to copy to
      chunkProcessor - a (possibly null) processor to handle the current Content.Chunk and its callback
      callback - the callback to notify when the copy is complete