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
- iftrue
the 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
copy
variant is by default registered inServerResponse
.- Parameters:
copy
- a signal if byte array should be copied - set ittrue
ifbyte[]
will be immediately reused.- Returns:
- a
byte[]
writer
-
charSequenceWriter
public static Function<CharSequence,Flow.Publisher<DataChunk>> charSequenceWriter(Charset charset)
Returns a writer function forCharSequence
using provided standardcharset
.An instance is by default registered in
ServerResponse
for all standard charsets.- Parameters:
charset
- a standard charset to use- Returns:
- a
String
writer - Throws:
NullPointerException
- if parametercharset
isnull
-
charBufferWriter
public static Function<CharBuffer,Flow.Publisher<DataChunk>> charBufferWriter(Charset charset)
Returns a writer function forCharBuffer
using provided standardcharset
.An instance is by default registered in
ServerResponse
for all standard charsets.- Parameters:
charset
- a standard charset to use- Returns:
- a
String
writer - Throws:
NullPointerException
- if parametercharset
isnull
-
byteChannelWriter
public static Function<ReadableByteChannel,Flow.Publisher<DataChunk>> byteChannelWriter(RetrySchema retrySchema)
Returns a writer function forReadableByteChannel
. Created publisher use providedRetrySchema
to define delay between unsuccessful read attempts.- Parameters:
retrySchema
- a retry schema to use in case whenread
operation reads0 bytes
- Returns:
- a
ReadableByteChannel
writer
-
byteChannelWriter
public static Function<ReadableByteChannel,Flow.Publisher<DataChunk>> byteChannelWriter()
Returns a writer function forReadableByteChannel
.- Returns:
- a
ReadableByteChannel
writer
-
-