- 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:
MessageBodyReaders
,MessageBodyFilters
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class io.helidon.media.common.MessageBodyContext
MessageBodyContext.ErrorEvent, MessageBodyContext.Event, MessageBodyContext.EventListener, MessageBodyContext.EventType
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Charset
charset()
Derive the charset to use from theContent-Type
header value or using a default charset as fallback.Optional<MediaType>
contentType()
Get theContent-Type
header.static MessageBodyReaderContext
create()
Create a new empty reader context backed by empty read-only headers.static MessageBodyReaderContext
create(MediaContext mediaContext, MessageBodyContext.EventListener eventListener, ReadOnlyParameters headers, Optional<MediaType> contentType)
Create a new empty reader context backed by the specified headers.static MessageBodyReaderContext
create(MessageBodyReaderContext parent)
Creates a new parented reader context.static MessageBodyReaderContext
create(MessageBodyReaderContext parent, MessageBodyContext.EventListener eventListener, ReadOnlyParameters headers, Optional<MediaType> contentType)
Create a new empty reader context backed by the specified headers.ReadOnlyParameters
headers()
Get the underlying headers.MessageBodyReaderContext
registerReader(MessageBodyReader<?> reader)
Register a reader.MessageBodyReaderContext
registerReader(MessageBodyStreamReader<?> reader)
Register a stream reader.<T> void
registerReader(Class<T> type, Reader<T> reader)
Deprecated.since 2.0.0 useregisterReader(MessageBodyReader)
instead<T> void
registerReader(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, registerFilter
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.helidon.media.common.MessageBodyFilters
registerFilter
-
-
-
-
Method Detail
-
create
public static MessageBodyReaderContext 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
-
registerReader
public MessageBodyReaderContext registerReader(MessageBodyReader<?> reader)
Description copied from interface:MessageBodyReaders
Register a reader.- Specified by:
registerReader
in interfaceMessageBodyReaders
- Parameters:
reader
- reader to register- Returns:
- Readers
-
registerReader
public MessageBodyReaderContext registerReader(MessageBodyStreamReader<?> reader)
Description copied from interface:MessageBodyReaders
Register a stream reader.- Specified by:
registerReader
in interfaceMessageBodyReaders
- Parameters:
reader
- reader to register- Returns:
- Readers
-
registerReader
@Deprecated public <T> void registerReader(Class<T> type, Reader<T> reader)
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 public <T> void registerReader(Predicate<Class<?>> predicate, Reader<T> reader)
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
public <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.- 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
public ReadOnlyParameters headers()
Get the underlying headers.- Returns:
- Parameters, never
null
-
contentType
public Optional<MediaType> contentType()
Get theContent-Type
header.- Returns:
- Optional, never
null
-
charset
public Charset charset() throws IllegalStateException
Description copied from class:MessageBodyContext
Derive the charset to use from theContent-Type
header value or using a default charset as fallback.- Specified by:
charset
in classMessageBodyContext
- Returns:
- Charset, never
null
- Throws:
IllegalStateException
- if an error occurs loading the charset specified by theContent-Type
header value
-
create
public static MessageBodyReaderContext create(MessageBodyReaderContext parent)
Creates a new parented reader context.- Parameters:
parent
- parent reader context- Returns:
- new instance of MessageBodyReaderContext
-
create
public static MessageBodyReaderContext create(MediaContext mediaContext, MessageBodyContext.EventListener eventListener, ReadOnlyParameters 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 benull
eventListener
- subscription event listener, may benull
headers
- backing headers, must not benull
contentType
- content type, must not benull
- Returns:
- MessageBodyReaderContext
-
create
public static MessageBodyReaderContext create(MessageBodyReaderContext parent, MessageBodyContext.EventListener eventListener, ReadOnlyParameters headers, Optional<MediaType> contentType)
Create a new empty reader context backed by the specified headers.- Parameters:
parent
- parent context, must not benull
eventListener
- subscription event listener, may benull
headers
- backing headers, must not benull
contentType
- content type, must not benull
- Returns:
- MessageBodyReaderContext
-
-