Package io.helidon.media.common
Class ContentWriters
- java.lang.Object
-
- io.helidon.media.common.ContentWriters
-
public final class ContentWriters extends Object
Utility class that provides standalone mechanisms for writing message body content.
-
-
Method Summary
-
-
-
Method Detail
-
writeBytes
public static Single<DataChunk> writeBytes(byte[] bytes, boolean copy)
- Parameters:
bytes- the byte arraycopy- iftruethe byte array is copied- Returns:
- Single
-
writeCharSequence
public static Single<DataChunk> writeCharSequence(CharSequence cs, Charset charset)
- Parameters:
cs- the char sequencecharset- the charset to use to encode the char sequence- Returns:
- Single
-
writeCharBuffer
public static Single<DataChunk> writeCharBuffer(CharBuffer buffer, Charset charset)
- Parameters:
buffer- the char buffercharset- the charset to use to encode the char sequence- Returns:
- Single
-
byteArrayWriter
public static Function<byte[],Flow.Publisher<DataChunk>> byteArrayWriter(boolean copy)
Returns a writer function forbyte[].The
copyvariant is by default registered inServerResponse.- Parameters:
copy- a signal if byte array should be copied - set ittrueifbyte[]will be immediately reused.- Returns:
- a
byte[]writer
-
charSequenceWriter
public static Function<CharSequence,Flow.Publisher<DataChunk>> charSequenceWriter(Charset charset)
Returns a writer function forCharSequenceusing provided standardcharset.An instance is by default registered in
ServerResponsefor all standard charsets.- Parameters:
charset- a standard charset to use- Returns:
- a
Stringwriter - Throws:
NullPointerException- if parametercharsetisnull
-
charBufferWriter
public static Function<CharBuffer,Flow.Publisher<DataChunk>> charBufferWriter(Charset charset)
Returns a writer function forCharBufferusing provided standardcharset.An instance is by default registered in
ServerResponsefor all standard charsets.- Parameters:
charset- a standard charset to use- Returns:
- a
Stringwriter - Throws:
NullPointerException- if parametercharsetisnull
-
byteChannelWriter
public static Function<ReadableByteChannel,Flow.Publisher<DataChunk>> byteChannelWriter(RetrySchema retrySchema)
Returns a writer function forReadableByteChannel. Created publisher use providedRetrySchemato define delay between unsuccessful read attempts.- Parameters:
retrySchema- a retry schema to use in case whenreadoperation reads0 bytes- Returns:
- a
ReadableByteChannelwriter
-
byteChannelWriter
public static Function<ReadableByteChannel,Flow.Publisher<DataChunk>> byteChannelWriter()
Returns a writer function forReadableByteChannel.- Returns:
- a
ReadableByteChannelwriter
-
-