Class AbstractStructSchema<T>

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static org.slf4j.Logger LOG  
      protected org.apache.pulsar.client.api.schema.SchemaReader<T> reader  
      protected org.apache.pulsar.common.schema.SchemaInfo schemaInfo  
      protected org.apache.pulsar.client.api.schema.SchemaInfoProvider schemaInfoProvider  
      protected org.apache.pulsar.client.api.schema.SchemaWriter<T> writer  
      • Fields inherited from interface org.apache.pulsar.client.api.Schema

        BOOL, BYTEBUFFER, BYTES, DATE, DOUBLE, FLOAT, INSTANT, INT16, INT32, INT64, INT8, LOCAL_DATE, LOCAL_DATE_TIME, LOCAL_TIME, STRING, TIME, TIMESTAMP
    • Constructor Summary

      Constructors 
      Constructor Description
      AbstractStructSchema​(org.apache.pulsar.common.schema.SchemaInfo schemaInfo)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.apache.pulsar.client.api.Schema<T> atSchemaVersion​(byte[] schemaVersion)
      Return an instance of this schema at the given version.
      T decode​(byte[] bytes)  
      T decode​(byte[] bytes, byte[] schemaVersion)  
      T decode​(io.netty.buffer.ByteBuf byteBuf)
      Decode a byteBuf into an object using the schema definition and deserializer implementation
      T decode​(io.netty.buffer.ByteBuf byteBuf, byte[] schemaVersion)
      Decode a byteBuf into an object using a given version.
      byte[] encode​(T message)  
      protected org.apache.pulsar.client.api.schema.SchemaReader<T> getReader()  
      org.apache.pulsar.common.schema.SchemaInfo getSchemaInfo()  
      protected void setReader​(org.apache.pulsar.client.api.schema.SchemaReader<T> reader)  
      void setSchemaInfoProvider​(org.apache.pulsar.client.api.schema.SchemaInfoProvider schemaInfoProvider)  
      protected void setWriter​(org.apache.pulsar.client.api.schema.SchemaWriter<T> writer)  
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface org.apache.pulsar.client.api.Schema

        configureSchemaInfo, decode, getNativeSchema, requireFetchingSchemaInfo, supportSchemaVersioning, validate
    • Field Detail

      • LOG

        protected static final org.slf4j.Logger LOG
      • schemaInfo

        protected final org.apache.pulsar.common.schema.SchemaInfo schemaInfo
      • reader

        protected org.apache.pulsar.client.api.schema.SchemaReader<T> reader
      • writer

        protected org.apache.pulsar.client.api.schema.SchemaWriter<T> writer
      • schemaInfoProvider

        protected org.apache.pulsar.client.api.schema.SchemaInfoProvider schemaInfoProvider
    • Constructor Detail

      • AbstractStructSchema

        public AbstractStructSchema​(org.apache.pulsar.common.schema.SchemaInfo schemaInfo)
    • Method Detail

      • encode

        public byte[] encode​(T message)
      • decode

        public T decode​(byte[] bytes)
      • decode

        public T decode​(byte[] bytes,
                        byte[] schemaVersion)
      • decode

        public T decode​(io.netty.buffer.ByteBuf byteBuf)
        Description copied from class: AbstractSchema
        Decode a byteBuf into an object using the schema definition and deserializer implementation

        Do not modify reader/writer index of ByteBuf so, it can be reused to access correct data.

        Specified by:
        decode in class AbstractSchema<T>
        Parameters:
        byteBuf - the byte buffer to decode
        Returns:
        the deserialized object
      • decode

        public T decode​(io.netty.buffer.ByteBuf byteBuf,
                        byte[] schemaVersion)
        Description copied from class: AbstractSchema
        Decode a byteBuf into an object using a given version.
        Overrides:
        decode in class AbstractSchema<T>
        Parameters:
        byteBuf - the byte array to decode
        schemaVersion - the schema version to decode the object. null indicates using latest version.
        Returns:
        the deserialized object
      • getSchemaInfo

        public org.apache.pulsar.common.schema.SchemaInfo getSchemaInfo()
      • setSchemaInfoProvider

        public void setSchemaInfoProvider​(org.apache.pulsar.client.api.schema.SchemaInfoProvider schemaInfoProvider)
      • atSchemaVersion

        public org.apache.pulsar.client.api.Schema<T> atSchemaVersion​(byte[] schemaVersion)
                                                               throws org.apache.pulsar.client.api.SchemaSerializationException
        Description copied from class: AbstractSchema
        Return an instance of this schema at the given version.
        Overrides:
        atSchemaVersion in class AbstractSchema<T>
        Parameters:
        schemaVersion - the version
        Returns:
        the schema at that specific version
        Throws:
        org.apache.pulsar.client.api.SchemaSerializationException - in case of unknown schema version
      • setWriter

        protected void setWriter​(org.apache.pulsar.client.api.schema.SchemaWriter<T> writer)
      • setReader

        protected void setReader​(org.apache.pulsar.client.api.schema.SchemaReader<T> reader)
      • getReader

        protected org.apache.pulsar.client.api.schema.SchemaReader<T> getReader()