java.lang.Object
io.helidon.media.common.MessageBodyContext
io.helidon.media.common.MessageBodyReaderContext
- All Implemented Interfaces:
MessageBodyFilters,MessageBodyReaders
public final class MessageBodyReaderContext
extends MessageBodyContext
implements MessageBodyReaders, MessageBodyFilters
Reader message body context.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class io.helidon.media.common.MessageBodyContext
MessageBodyContext.ErrorEvent, MessageBodyContext.Event, MessageBodyContext.EventListener, MessageBodyContext.EventType -
Method Summary
Modifier and TypeMethodDescriptioncharset()Derive the charset to use from theContent-Typeheader value or using a default charset as fallback.Get theContent-Typeheader.static MessageBodyReaderContextcreate()Create a new empty reader context backed by empty read-only headers.static MessageBodyReaderContextcreate(MediaContext mediaContext, MessageBodyContext.EventListener eventListener, ReadOnlyHeaders headers, Optional<MediaType> contentType) Create a new empty reader context backed by the specified headers.static MessageBodyReaderContextcreate(MediaContext mediaContext, MessageBodyContext.EventListener eventListener, ReadOnlyParameters headers, Optional<MediaType> contentType) Deprecated, for removal: This API element is subject to removal in a future version.static MessageBodyReaderContextcreate(MessageBodyReaderContext parent) Creates a new parented reader context.static MessageBodyReaderContextcreate(MessageBodyReaderContext parent, MessageBodyContext.EventListener eventListener, ReadOnlyHeaders headers, Optional<MediaType> contentType) Create a new empty reader context backed by the specified headers.static MessageBodyReaderContextcreate(MessageBodyReaderContext parent, MessageBodyContext.EventListener eventListener, ReadOnlyParameters headers, Optional<MediaType> contentType) Deprecated, for removal: This API element is subject to removal in a future version.Usecreate(MessageBodyReaderContext, io.helidon.media.common.MessageBodyContext.EventListener, io.helidon.common.http.ReadOnlyHeaders, java.util.Optional)instead, passingReadOnlyHeadersinstead ofReadOnlyParameters.headers()Get the underlying headers.longMaximum decoded input consumed by one materializing conversion.maxBufferedEntitySize(long size) Configure the decoded-input budget for each materializing conversion.maxBufferedEntitySize(long size, Supplier<? extends RuntimeException> exceptionSupplier) Configure a decoded-input budget and the failure used when it is exceeded.registerReader(MessageBodyReader<?> reader) Register a reader.registerReader(MessageBodyStreamReader<?> reader) Register a stream reader.<T> voidregisterReader(Class<T> type, Reader<T> reader) Deprecated.since 2.0.0 useregisterReader(MessageBodyReader)instead<T> voidregisterReader(Predicate<Class<?>> predicate, Reader<T> reader) Deprecated.since 2.0.0 useregisterReader(MessageBodyReader)instead<T> Single<T>unmarshall(Flow.Publisher<DataChunk> payload, GenericType<T> type) Convert a given HTTP payload into a publisher by selecting a reader that accepts the specified type and current context.<T> Single<T>unmarshall(Flow.Publisher<DataChunk> payload, MessageBodyReader<T> reader, GenericType<T> type) Convert a given HTTP payload into a publisher by selecting a reader with the specified class.<T> Flow.Publisher<T>unmarshallStream(Flow.Publisher<DataChunk> payload, GenericType<T> type) Convert a given HTTP payload into a publisher by selecting a stream reader that accepts the specified type and current context.<T> Flow.Publisher<T>unmarshallStream(Flow.Publisher<DataChunk> payload, MessageBodyStreamReader<T> reader, GenericType<T> type) Convert a given HTTP payload into a publisher by selecting a stream reader with the payload class.Methods inherited from class io.helidon.media.common.MessageBodyContext
applyFilters, applyFilters, registerFilterMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.helidon.media.common.MessageBodyFilters
registerFilter
-
Method Details
-
create
Create a new empty reader context backed by empty read-only headers. Such reader context is typically the parent context that is used to hold application wide readers and inbound filters.- Returns:
- MessageBodyWriterContext
-
create
Creates a new parented reader context.- Parameters:
parent- parent reader context- Returns:
- new instance of MessageBodyReaderContext
-
create
@Deprecated(since="3.0.3", forRemoval=true) public static MessageBodyReaderContext create(MediaContext mediaContext, MessageBodyContext.EventListener eventListener, ReadOnlyParameters headers, Optional<MediaType> contentType) Deprecated, for removal: This API element is subject to removal in a future version.Usecreate(MediaContext, io.helidon.media.common.MessageBodyContext.EventListener, io.helidon.common.http.ReadOnlyHeaders, java.util.Optional)instead, passingReadOnlyHeadersinstead ofReadOnlyParameters.Create a new empty reader context backed by the specified headers.- Parameters:
mediaContext- mediaSupport instance used to derived the parent context, may benulleventListener- subscription event listener, may benullheaders- backing headers, must not benullcontentType- content type, must not benull- Returns:
- MessageBodyReaderContext
-
create
public static MessageBodyReaderContext create(MediaContext mediaContext, MessageBodyContext.EventListener eventListener, ReadOnlyHeaders headers, Optional<MediaType> contentType) Create a new empty reader context backed by the specified headers.- Parameters:
mediaContext- mediaSupport instance used to derived the parent context, may benulleventListener- subscription event listener, may benullheaders- backing headers, must not benullcontentType- content type, must not benull- Returns:
- MessageBodyReaderContext
-
create
@Deprecated(since="3.0.3", forRemoval=true) public static MessageBodyReaderContext create(MessageBodyReaderContext parent, MessageBodyContext.EventListener eventListener, ReadOnlyParameters headers, Optional<MediaType> contentType) Deprecated, for removal: This API element is subject to removal in a future version.Usecreate(MessageBodyReaderContext, io.helidon.media.common.MessageBodyContext.EventListener, io.helidon.common.http.ReadOnlyHeaders, java.util.Optional)instead, passingReadOnlyHeadersinstead ofReadOnlyParameters.Create a new empty reader context backed by the specified headers.- Parameters:
parent- parent context, must not benulleventListener- subscription event listener, may benullheaders- backing headers, must not benullcontentType- content type, must not benull- Returns:
- MessageBodyReaderContext
-
create
public static MessageBodyReaderContext create(MessageBodyReaderContext parent, MessageBodyContext.EventListener eventListener, ReadOnlyHeaders headers, Optional<MediaType> contentType) Create a new empty reader context backed by the specified headers.- Parameters:
parent- parent context, must not benulleventListener- subscription event listener, may benullheaders- backing headers, must not benullcontentType- content type, must not benull- Returns:
- MessageBodyReaderContext
-
maxBufferedEntitySize
public long maxBufferedEntitySize()Maximum decoded input consumed by one materializing conversion. Streaming conversions are excluded. The default is 1 MiB (1,048,576 bytes); zero permits only empty entities. This bounds input bytes, rather than the resulting object graph. Each multipart part has its own budget.- Returns:
- maximum number of decoded bytes consumed by one materializing conversion
-
maxBufferedEntitySize
Configure the decoded-input budget for each materializing conversion. The default is 1 MiB (1,048,576 bytes). Zero permits only empty entities; negative values are rejected. Direct streams, stream readers, and readers declaringMessageBodyReader.streaming()are excluded.- Parameters:
size- maximum decoded input size in bytes- Returns:
- this context
- Throws:
IllegalArgumentException- ifsizeis negative
-
maxBufferedEntitySize
public MessageBodyReaderContext maxBufferedEntitySize(long size, Supplier<? extends RuntimeException> exceptionSupplier) Configure a decoded-input budget and the failure used when it is exceeded. Child contexts inherit this policy, including contexts for individual multipart parts. The supplier must return a non-null exception. The default failure isIllegalStateException.- Parameters:
size- maximum decoded input size in bytes; zero permits only empty entitiesexceptionSupplier- supplier of the exception for a materialization-limit failure- Returns:
- this context
- Throws:
IllegalArgumentException- ifsizeis negativeNullPointerException- ifexceptionSupplieris null
-
registerReader
Description copied from interface:MessageBodyReadersRegister a reader.- Specified by:
registerReaderin interfaceMessageBodyReaders- Parameters:
reader- reader to register- Returns:
- Readers
-
registerReader
Description copied from interface:MessageBodyReadersRegister a stream reader.- Specified by:
registerReaderin interfaceMessageBodyReaders- Parameters:
reader- reader to register- Returns:
- Readers
-
registerReader
Deprecated.since 2.0.0 useregisterReader(MessageBodyReader)insteadRegister a reader function with the given type.- Type Parameters:
T- supported type- Parameters:
type- class representing the supported typereader- reader function
-
registerReader
Deprecated.since 2.0.0 useregisterReader(MessageBodyReader)insteadRegister a reader function with the type predicate.- Type Parameters:
T- supported type- Parameters:
predicate- class predicatereader- reader function
-
unmarshall
Convert a given HTTP payload into a publisher by selecting a reader that accepts the specified type and current context.- Type Parameters:
T- entity type- Parameters:
payload- inbound payloadtype- actual representation of the entity type- Returns:
- publisher, never
null
-
unmarshall
public <T> Single<T> unmarshall(Flow.Publisher<DataChunk> payload, MessageBodyReader<T> reader, GenericType<T> type) Convert a given HTTP payload into a publisher by selecting a reader with the specified class.- Type Parameters:
T- entity type- Parameters:
payload- inbound payloadreader- specific readertype- actual representation of the entity type- Returns:
- publisher, never
null
-
unmarshallStream
public <T> Flow.Publisher<T> unmarshallStream(Flow.Publisher<DataChunk> payload, GenericType<T> type) Convert a given HTTP payload into a publisher by selecting a stream reader that accepts the specified type and current context.- Type Parameters:
T- entity type- Parameters:
payload- inbound payloadtype- actual representation of the entity type- Returns:
- publisher, never
null
-
unmarshallStream
public <T> Flow.Publisher<T> unmarshallStream(Flow.Publisher<DataChunk> payload, MessageBodyStreamReader<T> reader, GenericType<T> type) Convert a given HTTP payload into a publisher by selecting a stream reader with the payload class.- Type Parameters:
T- entity type- Parameters:
payload- inbound payloadreader- specific readertype- actual representation of the entity type- Returns:
- publisher, never
null
-
headers
Get the underlying headers.- Returns:
- headers, never
null
-
contentType
Get theContent-Typeheader.- Returns:
- Optional, never
null
-
charset
Description copied from class:MessageBodyContextDerive the charset to use from theContent-Typeheader value or using a default charset as fallback.- Specified by:
charsetin classMessageBodyContext- Returns:
- Charset, never
null - Throws:
IllegalStateException- if an error occurs loading the charset specified by theContent-Typeheader value
-
create(MediaContext, io.helidon.media.common.MessageBodyContext.EventListener, io.helidon.common.http.ReadOnlyHeaders, java.util.Optional)instead, passingReadOnlyHeadersinstead ofReadOnlyParameters.