Module io.cloudevents.core
Package io.cloudevents.core.message.impl
Class BaseGenericBinaryMessageReaderImpl<HK,HV>
java.lang.Object
io.cloudevents.core.message.impl.BaseBinaryMessageReader
io.cloudevents.core.message.impl.BaseGenericBinaryMessageReaderImpl<HK,HV>
- Type Parameters:
HK- Header key typeHV- Header value type
- All Implemented Interfaces:
MessageReader,StructuredMessageReader,io.cloudevents.rw.CloudEventReader
This class implements a Binary
MessageReader,
providing common logic to most protocol bindings which supports both Binary and Structured mode.
Content-type is handled separately using a key not prefixed with CloudEvents header prefix.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBaseGenericBinaryMessageReaderImpl(io.cloudevents.SpecVersion version, io.cloudevents.CloudEventData body) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidforEachHeader(BiConsumer<HK, HV> fn) Iterate over all the headers in the headers map.protected abstract booleanisCloudEventsHeader(HK key) protected abstract booleanisContentTypeHeader(HK key) <T extends io.cloudevents.rw.CloudEventWriter<V>,V>
Vread(io.cloudevents.rw.CloudEventWriterFactory<T, V> writerFactory, io.cloudevents.rw.CloudEventDataMapper<? extends io.cloudevents.CloudEventData> mapper) Read the message as binary encoded message using the provided writer factory.protected abstract StringtoCloudEventsKey(HK key) protected abstract StringtoCloudEventsValue(HV value) Methods inherited from class io.cloudevents.core.message.impl.BaseBinaryMessageReader
getEncoding, readMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.cloudevents.core.message.MessageReader
read, read, toEvent, toEvent
-
Constructor Details
-
BaseGenericBinaryMessageReaderImpl
protected BaseGenericBinaryMessageReaderImpl(io.cloudevents.SpecVersion version, io.cloudevents.CloudEventData body)
-
-
Method Details
-
read
public <T extends io.cloudevents.rw.CloudEventWriter<V>,V> V read(io.cloudevents.rw.CloudEventWriterFactory<T, V> writerFactory, io.cloudevents.rw.CloudEventDataMapper<? extends io.cloudevents.CloudEventData> mapper) throws io.cloudevents.rw.CloudEventRWException, IllegalStateExceptionDescription copied from interface:MessageReaderRead the message as binary encoded message using the provided writer factory.- Type Parameters:
T- theCloudEventWritertypeV- 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.
-
isContentTypeHeader
- Parameters:
key- header key- Returns:
- true if this header is the content type header, false otherwise
-
isCloudEventsHeader
- Parameters:
key- header key- Returns:
- true if this header is a CloudEvents header, false otherwise
-
toCloudEventsKey
- Parameters:
key- header key- Returns:
- the key converted to a CloudEvents context attribute/extension name
-
forEachHeader
Iterate over all the headers in the headers map.- Parameters:
fn- header consumer
-
toCloudEventsValue
- Parameters:
value- header key- Returns:
- the value converted to a valid CloudEvents attribute value as
String.
-