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 type
HV - Header value type
All Implemented Interfaces:
MessageReader, StructuredMessageReader, io.cloudevents.rw.CloudEventReader

public abstract class BaseGenericBinaryMessageReaderImpl<HK,HV> extends BaseBinaryMessageReader
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 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, IllegalStateException
      Description copied from interface: MessageReader
      Read the message as binary encoded message using the provided writer factory.
      Type Parameters:
      T - the CloudEventWriter type
      V - the return type of the CloudEventWriter
      Parameters:
      writerFactory - a factory that generates a reader starting from the SpecVersion of the event
      mapper - 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

      protected abstract boolean isContentTypeHeader(HK key)
      Parameters:
      key - header key
      Returns:
      true if this header is the content type header, false otherwise
    • isCloudEventsHeader

      protected abstract boolean isCloudEventsHeader(HK key)
      Parameters:
      key - header key
      Returns:
      true if this header is a CloudEvents header, false otherwise
    • toCloudEventsKey

      protected abstract String toCloudEventsKey(HK key)
      Parameters:
      key - header key
      Returns:
      the key converted to a CloudEvents context attribute/extension name
    • forEachHeader

      protected abstract void forEachHeader(BiConsumer<HK,HV> fn)
      Iterate over all the headers in the headers map.
      Parameters:
      fn - header consumer
    • toCloudEventsValue

      protected abstract String toCloudEventsValue(HV value)
      Parameters:
      value - header key
      Returns:
      the value converted to a valid CloudEvents attribute value as String.