接口 Codec<T>


public interface Codec<T>
Codec interface include encode and decode support.
从以下版本开始:
1.0.0
作者:
xiemalin
  • 方法概要

    修饰符和类型
    方法
    说明
    decode(byte[] bytes)
    Do decode action from byte array
    byte[]
    encode(T t)
    Do byte encode action
    com.google.protobuf.Descriptors.Descriptor
    Get Descriptor to support dynamic mesage call for protocol buffer
    readFrom(com.google.protobuf.CodedInputStream intput)
    Read object from target byte array input stream
    int
    size(T t)
    Calculate size of target object
    void
    writeTo(T t, com.google.protobuf.CodedOutputStream out)
    Write target object to byte array
  • 方法详细资料

    • encode

      byte[] encode(T t) throws IOException
      Do byte encode action
      参数:
      t - generic target object
      返回:
      encoded byte array
      抛出:
      IOException - if target object is invalid
    • decode

      T decode(byte[] bytes) throws IOException
      Do decode action from byte array
      参数:
      bytes - encoded byte array
      返回:
      parse byte array to target object
      抛出:
      IOException - if byte array is invalid
    • size

      int size(T t) throws IOException
      Calculate size of target object
      参数:
      t - target object
      返回:
      size of
      抛出:
      IOException - if target object is invalid
    • writeTo

      void writeTo(T t, com.google.protobuf.CodedOutputStream out) throws IOException
      Write target object to byte array
      参数:
      t - target object
      out - target CodedOutputStream
      抛出:
      IOException - if target object is invalid
    • readFrom

      T readFrom(com.google.protobuf.CodedInputStream intput) throws IOException
      Read object from target byte array input stream
      参数:
      intput - target input stream object
      返回:
      unserialize object
      抛出:
      IOException - if byte array is invalid
    • getDescriptor

      com.google.protobuf.Descriptors.Descriptor getDescriptor() throws IOException
      Get Descriptor to support dynamic mesage call for protocol buffer
      返回:
      Descriptors.Descriptor instance
      抛出:
      IOException - in case of create Descriptors.Descriptor failed