Class Content
Namespace class that contains the definitions of a content source
,
a content sink
and a content chunk
.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic 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 TypeMethodDescriptionstatic 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).
-
Method Details
-
copy
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 isfailed
.- Parameters:
source
- the source to copy fromsink
- the sink to copy tocallback
- 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 anychunkHandler
, the content source isfailed
if the failure chunk islast
, else the failure is transient and is ignored.- Parameters:
source
- the source to copy fromsink
- the sink to copy tochunkProcessor
- a (possiblynull
) processor to handle the currentContent.Chunk
and its callbackcallback
- the callback to notify when the copy is complete
-