Interface Reader

All Known Implementing Classes:
BinaryReader, BinaryReader.SafeHeapReader, CodedInputStreamReader

A reader of fields from a serialized protobuf message.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Value used to indicate that the end of input has been reached.
    static final int
    Value used to indicate that the reader does not know the tag about the field.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Gets the field number for the current field being read.
    int
    Gets the wire tag of the current field.
    <T> void
    mergeGroupField(T target, Schema<T> schema, ExtensionRegistryLite extensionRegistry)
    Read a group field from the wire format and merge the results into the given target.
    <T> void
    mergeMessageField(T target, Schema<T> schema, ExtensionRegistryLite extensionRegistry)
    Read a message field from the wire format and merge the results into the given target.
    boolean
    Reads and returns the next field of type BOOL and advances the reader to the next field.
    void
    Reads the next field of type BOOL_LIST or BOOL_LIST_PACKED and advances the reader to the next field.
    Reads and returns the next field of type BYTES and advances the reader to the next field.
    void
    Reads the next field of type BYTES_LIST and advances the reader to the next field.
    double
    Reads and returns the next field of type DOUBLE and advances the reader to the next field.
    void
    Reads the next field of type DOUBLE_LIST or DOUBLE_LIST_PACKED and advances the reader to the next field.
    int
    Reads and returns the next field of type ENUM and advances the reader to the next field.
    void
    Reads the next field of type ENUM_LIST or ENUM_LIST_PACKED and advances the reader to the next field.
    int
    Reads and returns the next field of type FIXED32 and advances the reader to the next field.
    void
    Reads the next field of type FIXED32_LIST or FIXED32_LIST_PACKED and advances the reader to the next field.
    long
    Reads and returns the next field of type FIXED64 and advances the reader to the next field.
    void
    Reads the next field of type FIXED64_LIST or FIXED64_LIST_PACKED and advances the reader to the next field.
    float
    Reads and returns the next field of type FLOAT and advances the reader to the next field.
    void
    Reads the next field of type FLOAT_LIST or FLOAT_LIST_PACKED and advances the reader to the next field.
    <T> T
    readGroup(Class<T> clazz, ExtensionRegistryLite extensionRegistry)
    Deprecated.
    groups fields are deprecated.
    <T> T
    Deprecated.
    <T> void
    readGroupList(List<T> target, Schema<T> targetType, ExtensionRegistryLite extensionRegistry)
    Deprecated.
    <T> void
    readGroupList(List<T> target, Class<T> targetType, ExtensionRegistryLite extensionRegistry)
    Deprecated.
    groups fields are deprecated.
    int
    Reads and returns the next field of type INT32 and advances the reader to the next field.
    void
    Reads the next field of type INT32_LIST or INT32_LIST_PACKED and advances the reader to the next field.
    long
    Reads and returns the next field of type INT64 and advances the reader to the next field.
    void
    Reads the next field of type INT64_LIST or INT64_LIST_PACKED and advances the reader to the next field.
    <K, V> void
    readMap(Map<K,V> target, MapEntryLite.Metadata<K,V> mapDefaultEntry, ExtensionRegistryLite extensionRegistry)
    Reads the next field of type MAP and advances the reader to the next field.
    <T> T
    readMessage(Class<T> clazz, ExtensionRegistryLite extensionRegistry)
    Reads and returns the next field of type MESSAGE and advances the reader to the next field.
    <T> T
     
    <T> void
    readMessageList(List<T> target, Schema<T> schema, ExtensionRegistryLite extensionRegistry)
    Reads the next field of type MESSAGE_LIST and advances the reader to the next field.
    <T> void
    readMessageList(List<T> target, Class<T> targetType, ExtensionRegistryLite extensionRegistry)
     
    int
    Reads and returns the next field of type SFIXED32 and advances the reader to the next field.
    void
    Reads the next field of type SFIXED32_LIST or SFIXED32_LIST_PACKED and advances the reader to the next field.
    long
    Reads and returns the next field of type SFIXED64 and advances the reader to the next field.
    void
    Reads the next field of type SFIXED64_LIST or SFIXED64_LIST_PACKED and advances the reader to the next field.
    int
    Reads and returns the next field of type SINT32 and advances the reader to the next field.
    void
    Reads the next field of type SINT32_LIST or SINT32_LIST_PACKED and advances the reader to the next field.
    long
    Reads and returns the next field of type SINT64 and advances the reader to the next field.
    void
    Reads the next field of type SINT64_LIST or SINT64_LIST_PACKED and advances the reader to the next field.
    Reads and returns the next field of type STRING and advances the reader to the next field.
    void
    Reads the next field of type STRING_LIST and advances the reader to the next field.
    void
    Reads the next field of type STRING_LIST and advances the reader to the next field.
    Reads and returns the next field of type STRING and advances the reader to the next field.
    int
    Reads and returns the next field of type UINT32 and advances the reader to the next field.
    void
    Reads the next field of type UINT32_LIST or UINT32_LIST_PACKED and advances the reader to the next field.
    long
    Reads and returns the next field of type UINT64 and advances the reader to the next field.
    void
    Reads the next field of type UINT64_LIST or UINT64_LIST_PACKED and advances the reader to the next field.
    boolean
     
    boolean
    Skips the current field and advances the reader to the next field.
  • Field Details

    • READ_DONE

      static final int READ_DONE
      Value used to indicate that the end of input has been reached.
      See Also:
    • TAG_UNKNOWN

      static final int TAG_UNKNOWN
      Value used to indicate that the reader does not know the tag about the field.
      See Also:
  • Method Details

    • shouldDiscardUnknownFields

      boolean shouldDiscardUnknownFields()
    • getFieldNumber

      int getFieldNumber() throws IOException
      Gets the field number for the current field being read.

      TODO: Rename it to make it more explicit about the side effect on the underlying buffer.

      Returns:
      the current field number or READ_DONE if the end of input has been reached.
      Throws:
      IOException
    • getTag

      int getTag()
      Gets the wire tag of the current field.
      Returns:
      the current wire tag or TAG_UNKNOWN if the reader does not know the tag of the current field.
    • skipField

      boolean skipField() throws IOException
      Skips the current field and advances the reader to the next field.
      Returns:
      true if there are more fields or false if the end of input has been reached.
      Throws:
      IOException
    • readDouble

      double readDouble() throws IOException
      Reads and returns the next field of type DOUBLE and advances the reader to the next field.
      Throws:
      IOException
    • readFloat

      float readFloat() throws IOException
      Reads and returns the next field of type FLOAT and advances the reader to the next field.
      Throws:
      IOException
    • readUInt64

      long readUInt64() throws IOException
      Reads and returns the next field of type UINT64 and advances the reader to the next field.
      Throws:
      IOException
    • readInt64

      long readInt64() throws IOException
      Reads and returns the next field of type INT64 and advances the reader to the next field.
      Throws:
      IOException
    • readInt32

      int readInt32() throws IOException
      Reads and returns the next field of type INT32 and advances the reader to the next field.
      Throws:
      IOException
    • readFixed64

      long readFixed64() throws IOException
      Reads and returns the next field of type FIXED64 and advances the reader to the next field.
      Throws:
      IOException
    • readFixed32

      int readFixed32() throws IOException
      Reads and returns the next field of type FIXED32 and advances the reader to the next field.
      Throws:
      IOException
    • readBool

      boolean readBool() throws IOException
      Reads and returns the next field of type BOOL and advances the reader to the next field.
      Throws:
      IOException
    • readString

      String readString() throws IOException
      Reads and returns the next field of type STRING and advances the reader to the next field. If the stream contains malformed UTF-8, replace the offending bytes with the standard UTF-8 replacement character.
      Throws:
      IOException
    • readStringRequireUtf8

      String readStringRequireUtf8() throws IOException
      Reads and returns the next field of type STRING and advances the reader to the next field. If the stream contains malformed UTF-8, throw exception InvalidProtocolBufferException.
      Throws:
      IOException
    • readMessageBySchemaWithCheck

      <T> T readMessageBySchemaWithCheck(Schema<T> schema, ExtensionRegistryLite extensionRegistry) throws IOException
      Throws:
      IOException
    • readMessage

      <T> T readMessage(Class<T> clazz, ExtensionRegistryLite extensionRegistry) throws IOException
      Reads and returns the next field of type MESSAGE and advances the reader to the next field.
      Throws:
      IOException
    • readGroup

      @Deprecated <T> T readGroup(Class<T> clazz, ExtensionRegistryLite extensionRegistry) throws IOException
      Deprecated.
      groups fields are deprecated.
      Reads and returns the next field of type GROUP and advances the reader to the next field.
      Throws:
      IOException
    • readGroupBySchemaWithCheck

      @Deprecated <T> T readGroupBySchemaWithCheck(Schema<T> schema, ExtensionRegistryLite extensionRegistry) throws IOException
      Deprecated.
      Throws:
      IOException
    • mergeMessageField

      <T> void mergeMessageField(T target, Schema<T> schema, ExtensionRegistryLite extensionRegistry) throws IOException
      Read a message field from the wire format and merge the results into the given target.
      Throws:
      IOException
    • mergeGroupField

      <T> void mergeGroupField(T target, Schema<T> schema, ExtensionRegistryLite extensionRegistry) throws IOException
      Read a group field from the wire format and merge the results into the given target.
      Throws:
      IOException
    • readBytes

      ByteString readBytes() throws IOException
      Reads and returns the next field of type BYTES and advances the reader to the next field.
      Throws:
      IOException
    • readUInt32

      int readUInt32() throws IOException
      Reads and returns the next field of type UINT32 and advances the reader to the next field.
      Throws:
      IOException
    • readEnum

      int readEnum() throws IOException
      Reads and returns the next field of type ENUM and advances the reader to the next field.
      Throws:
      IOException
    • readSFixed32

      int readSFixed32() throws IOException
      Reads and returns the next field of type SFIXED32 and advances the reader to the next field.
      Throws:
      IOException
    • readSFixed64

      long readSFixed64() throws IOException
      Reads and returns the next field of type SFIXED64 and advances the reader to the next field.
      Throws:
      IOException
    • readSInt32

      int readSInt32() throws IOException
      Reads and returns the next field of type SINT32 and advances the reader to the next field.
      Throws:
      IOException
    • readSInt64

      long readSInt64() throws IOException
      Reads and returns the next field of type SINT64 and advances the reader to the next field.
      Throws:
      IOException
    • readDoubleList

      void readDoubleList(List<Double> target) throws IOException
      Reads the next field of type DOUBLE_LIST or DOUBLE_LIST_PACKED and advances the reader to the next field.
      Parameters:
      target - the list that will receive the read values.
      Throws:
      IOException
    • readFloatList

      void readFloatList(List<Float> target) throws IOException
      Reads the next field of type FLOAT_LIST or FLOAT_LIST_PACKED and advances the reader to the next field.
      Parameters:
      target - the list that will receive the read values.
      Throws:
      IOException
    • readUInt64List

      void readUInt64List(List<Long> target) throws IOException
      Reads the next field of type UINT64_LIST or UINT64_LIST_PACKED and advances the reader to the next field.
      Parameters:
      target - the list that will receive the read values.
      Throws:
      IOException
    • readInt64List

      void readInt64List(List<Long> target) throws IOException
      Reads the next field of type INT64_LIST or INT64_LIST_PACKED and advances the reader to the next field.
      Parameters:
      target - the list that will receive the read values.
      Throws:
      IOException
    • readInt32List

      void readInt32List(List<Integer> target) throws IOException
      Reads the next field of type INT32_LIST or INT32_LIST_PACKED and advances the reader to the next field.
      Parameters:
      target - the list that will receive the read values.
      Throws:
      IOException
    • readFixed64List

      void readFixed64List(List<Long> target) throws IOException
      Reads the next field of type FIXED64_LIST or FIXED64_LIST_PACKED and advances the reader to the next field.
      Parameters:
      target - the list that will receive the read values.
      Throws:
      IOException
    • readFixed32List

      void readFixed32List(List<Integer> target) throws IOException
      Reads the next field of type FIXED32_LIST or FIXED32_LIST_PACKED and advances the reader to the next field.
      Parameters:
      target - the list that will receive the read values.
      Throws:
      IOException
    • readBoolList

      void readBoolList(List<Boolean> target) throws IOException
      Reads the next field of type BOOL_LIST or BOOL_LIST_PACKED and advances the reader to the next field.
      Parameters:
      target - the list that will receive the read values.
      Throws:
      IOException
    • readStringList

      void readStringList(List<String> target) throws IOException
      Reads the next field of type STRING_LIST and advances the reader to the next field.
      Parameters:
      target - the list that will receive the read values.
      Throws:
      IOException
    • readStringListRequireUtf8

      void readStringListRequireUtf8(List<String> target) throws IOException
      Reads the next field of type STRING_LIST and advances the reader to the next field. If the stream contains malformed UTF-8, throw exception InvalidProtocolBufferException.
      Parameters:
      target - the list that will receive the read values.
      Throws:
      IOException
    • readMessageList

      <T> void readMessageList(List<T> target, Schema<T> schema, ExtensionRegistryLite extensionRegistry) throws IOException
      Reads the next field of type MESSAGE_LIST and advances the reader to the next field.
      Parameters:
      target - the list that will receive the read values.
      targetType - the type of the elements stored in the target list.
      Throws:
      IOException
    • readMessageList

      <T> void readMessageList(List<T> target, Class<T> targetType, ExtensionRegistryLite extensionRegistry) throws IOException
      Throws:
      IOException
    • readGroupList

      @Deprecated <T> void readGroupList(List<T> target, Class<T> targetType, ExtensionRegistryLite extensionRegistry) throws IOException
      Deprecated.
      groups fields are deprecated.
      Reads the next field of type GROUP_LIST and advances the reader to the next field.
      Parameters:
      target - the list that will receive the read values.
      targetType - the type of the elements stored in the target list.
      Throws:
      IOException
    • readGroupList

      @Deprecated <T> void readGroupList(List<T> target, Schema<T> targetType, ExtensionRegistryLite extensionRegistry) throws IOException
      Deprecated.
      Throws:
      IOException
    • readBytesList

      void readBytesList(List<ByteString> target) throws IOException
      Reads the next field of type BYTES_LIST and advances the reader to the next field.
      Parameters:
      target - the list that will receive the read values.
      Throws:
      IOException
    • readUInt32List

      void readUInt32List(List<Integer> target) throws IOException
      Reads the next field of type UINT32_LIST or UINT32_LIST_PACKED and advances the reader to the next field.
      Parameters:
      target - the list that will receive the read values.
      Throws:
      IOException
    • readEnumList

      void readEnumList(List<Integer> target) throws IOException
      Reads the next field of type ENUM_LIST or ENUM_LIST_PACKED and advances the reader to the next field.
      Parameters:
      target - the list that will receive the read values.
      Throws:
      IOException
    • readSFixed32List

      void readSFixed32List(List<Integer> target) throws IOException
      Reads the next field of type SFIXED32_LIST or SFIXED32_LIST_PACKED and advances the reader to the next field.
      Parameters:
      target - the list that will receive the read values.
      Throws:
      IOException
    • readSFixed64List

      void readSFixed64List(List<Long> target) throws IOException
      Reads the next field of type SFIXED64_LIST or SFIXED64_LIST_PACKED and advances the reader to the next field.
      Parameters:
      target - the list that will receive the read values.
      Throws:
      IOException
    • readSInt32List

      void readSInt32List(List<Integer> target) throws IOException
      Reads the next field of type SINT32_LIST or SINT32_LIST_PACKED and advances the reader to the next field.
      Parameters:
      target - the list that will receive the read values.
      Throws:
      IOException
    • readSInt64List

      void readSInt64List(List<Long> target) throws IOException
      Reads the next field of type SINT64_LIST or SINT64_LIST_PACKED and advances the reader to the next field.
      Parameters:
      target - the list that will receive the read values.
      Throws:
      IOException
    • readMap

      <K, V> void readMap(Map<K,V> target, MapEntryLite.Metadata<K,V> mapDefaultEntry, ExtensionRegistryLite extensionRegistry) throws IOException
      Reads the next field of type MAP and advances the reader to the next field.
      Parameters:
      target - the mutable map that will receive the read values.
      mapDefaultEntry - the default entry of the map field.
      extensionRegistry - the extension registry for parsing message value fields.
      Throws:
      IOException