Interface Reader

    • Field Summary

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

      All Methods Instance Methods Abstract Methods Deprecated Methods 
      Modifier and Type Method Description
      int getFieldNumber()
      Gets the field number for the current field being read.
      int getTag()
      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 readBool()
      Reads and returns the next field of type BOOL and advances the reader to the next field.
      void readBoolList​(java.util.List<java.lang.Boolean> target)
      Reads the next field of type BOOL_LIST or BOOL_LIST_PACKED and advances the reader to the next field.
      ByteString readBytes()
      Reads and returns the next field of type BYTES and advances the reader to the next field.
      void readBytesList​(java.util.List<ByteString> target)
      Reads the next field of type BYTES_LIST and advances the reader to the next field.
      double readDouble()
      Reads and returns the next field of type DOUBLE and advances the reader to the next field.
      void readDoubleList​(java.util.List<java.lang.Double> target)
      Reads the next field of type DOUBLE_LIST or DOUBLE_LIST_PACKED and advances the reader to the next field.
      int readEnum()
      Reads and returns the next field of type ENUM and advances the reader to the next field.
      void readEnumList​(java.util.List<java.lang.Integer> target)
      Reads the next field of type ENUM_LIST or ENUM_LIST_PACKED and advances the reader to the next field.
      int readFixed32()
      Reads and returns the next field of type FIXED32 and advances the reader to the next field.
      void readFixed32List​(java.util.List<java.lang.Integer> target)
      Reads the next field of type FIXED32_LIST or FIXED32_LIST_PACKED and advances the reader to the next field.
      long readFixed64()
      Reads and returns the next field of type FIXED64 and advances the reader to the next field.
      void readFixed64List​(java.util.List<java.lang.Long> target)
      Reads the next field of type FIXED64_LIST or FIXED64_LIST_PACKED and advances the reader to the next field.
      float readFloat()
      Reads and returns the next field of type FLOAT and advances the reader to the next field.
      void readFloatList​(java.util.List<java.lang.Float> target)
      Reads the next field of type FLOAT_LIST or FLOAT_LIST_PACKED and advances the reader to the next field.
      <T> T readGroup​(java.lang.Class<T> clazz, ExtensionRegistryLite extensionRegistry)
      Deprecated.
      groups fields are deprecated.
      <T> T readGroupBySchemaWithCheck​(Schema<T> schema, ExtensionRegistryLite extensionRegistry)
      Deprecated.
      <T> void readGroupList​(java.util.List<T> target, Schema<T> targetType, ExtensionRegistryLite extensionRegistry)
      Deprecated.
      <T> void readGroupList​(java.util.List<T> target, java.lang.Class<T> targetType, ExtensionRegistryLite extensionRegistry)
      Deprecated.
      groups fields are deprecated.
      int readInt32()
      Reads and returns the next field of type INT32 and advances the reader to the next field.
      void readInt32List​(java.util.List<java.lang.Integer> target)
      Reads the next field of type INT32_LIST or INT32_LIST_PACKED and advances the reader to the next field.
      long readInt64()
      Reads and returns the next field of type INT64 and advances the reader to the next field.
      void readInt64List​(java.util.List<java.lang.Long> target)
      Reads the next field of type INT64_LIST or INT64_LIST_PACKED and advances the reader to the next field.
      <K,​V>
      void
      readMap​(java.util.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​(java.lang.Class<T> clazz, ExtensionRegistryLite extensionRegistry)
      Reads and returns the next field of type MESSAGE and advances the reader to the next field.
      <T> T readMessageBySchemaWithCheck​(Schema<T> schema, ExtensionRegistryLite extensionRegistry)  
      <T> void readMessageList​(java.util.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​(java.util.List<T> target, java.lang.Class<T> targetType, ExtensionRegistryLite extensionRegistry)  
      int readSFixed32()
      Reads and returns the next field of type SFIXED32 and advances the reader to the next field.
      void readSFixed32List​(java.util.List<java.lang.Integer> target)
      Reads the next field of type SFIXED32_LIST or SFIXED32_LIST_PACKED and advances the reader to the next field.
      long readSFixed64()
      Reads and returns the next field of type SFIXED64 and advances the reader to the next field.
      void readSFixed64List​(java.util.List<java.lang.Long> target)
      Reads the next field of type SFIXED64_LIST or SFIXED64_LIST_PACKED and advances the reader to the next field.
      int readSInt32()
      Reads and returns the next field of type SINT32 and advances the reader to the next field.
      void readSInt32List​(java.util.List<java.lang.Integer> target)
      Reads the next field of type SINT32_LIST or SINT32_LIST_PACKED and advances the reader to the next field.
      long readSInt64()
      Reads and returns the next field of type SINT64 and advances the reader to the next field.
      void readSInt64List​(java.util.List<java.lang.Long> target)
      Reads the next field of type SINT64_LIST or SINT64_LIST_PACKED and advances the reader to the next field.
      java.lang.String readString()
      Reads and returns the next field of type STRING and advances the reader to the next field.
      void readStringList​(java.util.List<java.lang.String> target)
      Reads the next field of type STRING_LIST and advances the reader to the next field.
      void readStringListRequireUtf8​(java.util.List<java.lang.String> target)
      Reads the next field of type STRING_LIST and advances the reader to the next field.
      java.lang.String readStringRequireUtf8()
      Reads and returns the next field of type STRING and advances the reader to the next field.
      int readUInt32()
      Reads and returns the next field of type UINT32 and advances the reader to the next field.
      void readUInt32List​(java.util.List<java.lang.Integer> target)
      Reads the next field of type UINT32_LIST or UINT32_LIST_PACKED and advances the reader to the next field.
      long readUInt64()
      Reads and returns the next field of type UINT64 and advances the reader to the next field.
      void readUInt64List​(java.util.List<java.lang.Long> target)
      Reads the next field of type UINT64_LIST or UINT64_LIST_PACKED and advances the reader to the next field.
      boolean shouldDiscardUnknownFields()  
      boolean skipField()
      Skips the current field and advances the reader to the next field.
    • Field Detail

      • READ_DONE

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

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

      • shouldDiscardUnknownFields

        boolean shouldDiscardUnknownFields()
      • getFieldNumber

        int getFieldNumber()
                    throws java.io.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:
        java.io.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 java.io.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:
        java.io.IOException
      • readDouble

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

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

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

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

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

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

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

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

        java.lang.String readString()
                             throws java.io.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:
        java.io.IOException
      • readStringRequireUtf8

        java.lang.String readStringRequireUtf8()
                                        throws java.io.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:
        java.io.IOException
      • readMessageBySchemaWithCheck

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

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

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

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

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

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

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

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

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

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

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

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

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

        void readDoubleList​(java.util.List<java.lang.Double> target)
                     throws java.io.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:
        java.io.IOException
      • readFloatList

        void readFloatList​(java.util.List<java.lang.Float> target)
                    throws java.io.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:
        java.io.IOException
      • readUInt64List

        void readUInt64List​(java.util.List<java.lang.Long> target)
                     throws java.io.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:
        java.io.IOException
      • readInt64List

        void readInt64List​(java.util.List<java.lang.Long> target)
                    throws java.io.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:
        java.io.IOException
      • readInt32List

        void readInt32List​(java.util.List<java.lang.Integer> target)
                    throws java.io.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:
        java.io.IOException
      • readFixed64List

        void readFixed64List​(java.util.List<java.lang.Long> target)
                      throws java.io.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:
        java.io.IOException
      • readFixed32List

        void readFixed32List​(java.util.List<java.lang.Integer> target)
                      throws java.io.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:
        java.io.IOException
      • readBoolList

        void readBoolList​(java.util.List<java.lang.Boolean> target)
                   throws java.io.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:
        java.io.IOException
      • readStringList

        void readStringList​(java.util.List<java.lang.String> target)
                     throws java.io.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:
        java.io.IOException
      • readStringListRequireUtf8

        void readStringListRequireUtf8​(java.util.List<java.lang.String> target)
                                throws java.io.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:
        java.io.IOException
      • readMessageList

        <T> void readMessageList​(java.util.List<T> target,
                                 Schema<T> schema,
                                 ExtensionRegistryLite extensionRegistry)
                          throws java.io.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:
        java.io.IOException
      • readMessageList

        <T> void readMessageList​(java.util.List<T> target,
                                 java.lang.Class<T> targetType,
                                 ExtensionRegistryLite extensionRegistry)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • readGroupList

        @Deprecated
        <T> void readGroupList​(java.util.List<T> target,
                               java.lang.Class<T> targetType,
                               ExtensionRegistryLite extensionRegistry)
                        throws java.io.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:
        java.io.IOException
      • readGroupList

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

        void readBytesList​(java.util.List<ByteString> target)
                    throws java.io.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:
        java.io.IOException
      • readUInt32List

        void readUInt32List​(java.util.List<java.lang.Integer> target)
                     throws java.io.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:
        java.io.IOException
      • readEnumList

        void readEnumList​(java.util.List<java.lang.Integer> target)
                   throws java.io.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:
        java.io.IOException
      • readSFixed32List

        void readSFixed32List​(java.util.List<java.lang.Integer> target)
                       throws java.io.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:
        java.io.IOException
      • readSFixed64List

        void readSFixed64List​(java.util.List<java.lang.Long> target)
                       throws java.io.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:
        java.io.IOException
      • readSInt32List

        void readSInt32List​(java.util.List<java.lang.Integer> target)
                     throws java.io.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:
        java.io.IOException
      • readSInt64List

        void readSInt64List​(java.util.List<java.lang.Long> target)
                     throws java.io.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:
        java.io.IOException
      • readMap

        <K,​V> void readMap​(java.util.Map<K,​V> target,
                                 MapEntryLite.Metadata<K,​V> mapDefaultEntry,
                                 ExtensionRegistryLite extensionRegistry)
                          throws java.io.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:
        java.io.IOException