- All Superinterfaces:
io.cloudevents.rw.CloudEventReader,StructuredMessageReader
- All Known Implementing Classes:
BaseBinaryMessageReader,BaseGenericBinaryMessageReaderImpl,BaseStructuredMessageReader,GenericStructuredMessageReader
@ParametersAreNonnullByDefault
public interface MessageReader
extends StructuredMessageReader, io.cloudevents.rw.CloudEventReader
Represents a CloudEvent message reader.
This class expands the CloudEventReader to define reading both binary and structured messages.
-
Method Summary
Modifier and TypeMethodDescriptiondefault <BW extends io.cloudevents.rw.CloudEventWriter<R>,R>
Rread(MessageWriter<BW, R> writer) Read the content of this object using aMessageWriter.<R> Rread(StructuredMessageWriter<R> writer) Read the message as structured encoded message using the provided writerdefault <W extends io.cloudevents.rw.CloudEventWriter<R>,R>
Rread(io.cloudevents.rw.CloudEventWriterFactory<W, R> writerFactory) Likeread(CloudEventWriterFactory, CloudEventDataMapper), but with the identityCloudEventDataMapper.<W extends io.cloudevents.rw.CloudEventWriter<R>,R>
Rread(io.cloudevents.rw.CloudEventWriterFactory<W, R> writerFactory, io.cloudevents.rw.CloudEventDataMapper<? extends io.cloudevents.CloudEventData> mapper) Read the message as binary encoded message using the provided writer factory.default io.cloudevents.CloudEventtoEvent()LiketoEvent(CloudEventDataMapper), but with the identityCloudEventDataMapper.default io.cloudevents.CloudEventtoEvent(io.cloudevents.rw.CloudEventDataMapper<? extends io.cloudevents.CloudEventData> mapper) Translate this message into aCloudEventrepresentation, mapping the data with the providedmapper.
-
Method Details
-
read
default <W extends io.cloudevents.rw.CloudEventWriter<R>,R> R read(io.cloudevents.rw.CloudEventWriterFactory<W, R> writerFactory) throws io.cloudevents.rw.CloudEventRWException, IllegalStateExceptionLikeread(CloudEventWriterFactory, CloudEventDataMapper), but with the identityCloudEventDataMapper.- Specified by:
readin interfaceio.cloudevents.rw.CloudEventReader- Throws:
io.cloudevents.rw.CloudEventRWExceptionIllegalStateException- See Also:
-
read
<W extends io.cloudevents.rw.CloudEventWriter<R>,R> R read(io.cloudevents.rw.CloudEventWriterFactory<W, R> writerFactory, io.cloudevents.rw.CloudEventDataMapper<? extends io.cloudevents.CloudEventData> mapper) throws io.cloudevents.rw.CloudEventRWException, IllegalStateExceptionRead the message as binary encoded message using the provided writer factory.- Specified by:
readin interfaceio.cloudevents.rw.CloudEventReader- Type Parameters:
W- theCloudEventWritertypeR- the return type of theCloudEventWriter- Parameters:
writerFactory- a factory that generates a reader starting from theSpecVersionof the eventmapper- the mapper to use to map the data, if any.- Throws:
io.cloudevents.rw.CloudEventRWException- if something went wrong during the visit.IllegalStateException- if the message is not in binary encoding.
-
read
<R> R read(StructuredMessageWriter<R> writer) throws io.cloudevents.rw.CloudEventRWException, IllegalStateException Read the message as structured encoded message using the provided writer- Specified by:
readin interfaceStructuredMessageReader- Type Parameters:
R- the return type of theStructuredMessageWriter- Parameters:
writer- Structured Message writer- Returns:
- the return value returned by
StructuredMessageWriter.setEvent(EventFormat, byte[]) - Throws:
io.cloudevents.rw.CloudEventRWException- if something went wrong during the visit.IllegalStateException- if the message is not in structured encoding.
-
getEncoding
Encoding getEncoding()- Returns:
- The message encoding
-
read
default <BW extends io.cloudevents.rw.CloudEventWriter<R>,R> R read(MessageWriter<BW, R> writer) throws io.cloudevents.rw.CloudEventRWException, IllegalStateExceptionRead the content of this object using aMessageWriter. This method allows to transcode an event from one transport to another without converting it toCloudEvent. The resulting encoding will be the same as the original encoding.- Type Parameters:
BW- theCloudEventWritertypeR- the return type of bothCloudEventWriterandStructuredMessageWriter- Parameters:
writer- theMessageWriteraccepting this Message- Returns:
- The return value of the
MessageWriter - Throws:
io.cloudevents.rw.CloudEventRWException- if something went wrong during the visit.IllegalStateException- if the message has an unknown encoding.
-
toEvent
default io.cloudevents.CloudEvent toEvent() throws io.cloudevents.rw.CloudEventRWException, IllegalStateExceptionLiketoEvent(CloudEventDataMapper), but with the identityCloudEventDataMapper.- Specified by:
toEventin interfaceStructuredMessageReader- Throws:
io.cloudevents.rw.CloudEventRWExceptionIllegalStateException- See Also:
-
toEvent
default io.cloudevents.CloudEvent toEvent(io.cloudevents.rw.CloudEventDataMapper<? extends io.cloudevents.CloudEventData> mapper) throws io.cloudevents.rw.CloudEventRWException, IllegalStateException Translate this message into aCloudEventrepresentation, mapping the data with the providedmapper.- Specified by:
toEventin interfaceStructuredMessageReader- Parameters:
mapper- the mapper to use to map the data, if any.- Returns:
- A
CloudEventwith the contents of this message. - Throws:
io.cloudevents.rw.CloudEventRWException- if something went wrong during the read.IllegalStateException- if the message has an unknown encoding.
-