Package com.google.protobuf
Interface Reader
- All Known Implementing Classes:
BinaryReader
,BinaryReader.SafeHeapReader
,CodedInputStreamReader
A reader of fields from a serialized protobuf message.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic 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 TypeMethodDescriptionint
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 typeBOOL
and advances the reader to the next field.void
readBoolList
(List<Boolean> target) Reads the next field of typeBOOL_LIST
orBOOL_LIST_PACKED
and advances the reader to the next field.Reads and returns the next field of typeBYTES
and advances the reader to the next field.void
readBytesList
(List<ByteString> target) Reads the next field of typeBYTES_LIST
and advances the reader to the next field.double
Reads and returns the next field of typeDOUBLE
and advances the reader to the next field.void
readDoubleList
(List<Double> target) Reads the next field of typeDOUBLE_LIST
orDOUBLE_LIST_PACKED
and advances the reader to the next field.int
readEnum()
Reads and returns the next field of typeENUM
and advances the reader to the next field.void
readEnumList
(List<Integer> target) Reads the next field of typeENUM_LIST
orENUM_LIST_PACKED
and advances the reader to the next field.int
Reads and returns the next field of typeFIXED32
and advances the reader to the next field.void
readFixed32List
(List<Integer> target) Reads the next field of typeFIXED32_LIST
orFIXED32_LIST_PACKED
and advances the reader to the next field.long
Reads and returns the next field of typeFIXED64
and advances the reader to the next field.void
readFixed64List
(List<Long> target) Reads the next field of typeFIXED64_LIST
orFIXED64_LIST_PACKED
and advances the reader to the next field.float
Reads and returns the next field of typeFLOAT
and advances the reader to the next field.void
readFloatList
(List<Float> target) Reads the next field of typeFLOAT_LIST
orFLOAT_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
readGroupBySchemaWithCheck
(Schema<T> schema, ExtensionRegistryLite extensionRegistry) 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 typeINT32
and advances the reader to the next field.void
readInt32List
(List<Integer> target) Reads the next field of typeINT32_LIST
orINT32_LIST_PACKED
and advances the reader to the next field.long
Reads and returns the next field of typeINT64
and advances the reader to the next field.void
readInt64List
(List<Long> target) Reads the next field of typeINT64_LIST
orINT64_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 typeMAP
and advances the reader to the next field.<T> T
readMessage
(Class<T> clazz, ExtensionRegistryLite extensionRegistry) Reads and returns the next field of typeMESSAGE
and advances the reader to the next field.<T> T
readMessageBySchemaWithCheck
(Schema<T> schema, ExtensionRegistryLite extensionRegistry) <T> void
readMessageList
(List<T> target, Schema<T> schema, ExtensionRegistryLite extensionRegistry) Reads the next field of typeMESSAGE_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 typeSFIXED32
and advances the reader to the next field.void
readSFixed32List
(List<Integer> target) Reads the next field of typeSFIXED32_LIST
orSFIXED32_LIST_PACKED
and advances the reader to the next field.long
Reads and returns the next field of typeSFIXED64
and advances the reader to the next field.void
readSFixed64List
(List<Long> target) Reads the next field of typeSFIXED64_LIST
orSFIXED64_LIST_PACKED
and advances the reader to the next field.int
Reads and returns the next field of typeSINT32
and advances the reader to the next field.void
readSInt32List
(List<Integer> target) Reads the next field of typeSINT32_LIST
orSINT32_LIST_PACKED
and advances the reader to the next field.long
Reads and returns the next field of typeSINT64
and advances the reader to the next field.void
readSInt64List
(List<Long> target) Reads the next field of typeSINT64_LIST
orSINT64_LIST_PACKED
and advances the reader to the next field.Reads and returns the next field of typeSTRING
and advances the reader to the next field.void
readStringList
(List<String> target) Reads the next field of typeSTRING_LIST
and advances the reader to the next field.void
readStringListRequireUtf8
(List<String> target) Reads the next field of typeSTRING_LIST
and advances the reader to the next field.Reads and returns the next field of typeSTRING
and advances the reader to the next field.int
Reads and returns the next field of typeUINT32
and advances the reader to the next field.void
readUInt32List
(List<Integer> target) Reads the next field of typeUINT32_LIST
orUINT32_LIST_PACKED
and advances the reader to the next field.long
Reads and returns the next field of typeUINT64
and advances the reader to the next field.void
readUInt64List
(List<Long> target) Reads the next field of typeUINT64_LIST
orUINT64_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_DONEValue used to indicate that the end of input has been reached.- See Also:
-
TAG_UNKNOWN
static final int TAG_UNKNOWNValue used to indicate that the reader does not know the tag about the field.- See Also:
-
-
Method Details
-
shouldDiscardUnknownFields
boolean shouldDiscardUnknownFields() -
getFieldNumber
Gets the field number for the current field being read.TODO(liujisi): 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
Skips the current field and advances the reader to the next field.- Returns:
true
if there are more fields orfalse
if the end of input has been reached.- Throws:
IOException
-
readDouble
Reads and returns the next field of typeDOUBLE
and advances the reader to the next field.- Throws:
IOException
-
readFloat
Reads and returns the next field of typeFLOAT
and advances the reader to the next field.- Throws:
IOException
-
readUInt64
Reads and returns the next field of typeUINT64
and advances the reader to the next field.- Throws:
IOException
-
readInt64
Reads and returns the next field of typeINT64
and advances the reader to the next field.- Throws:
IOException
-
readInt32
Reads and returns the next field of typeINT32
and advances the reader to the next field.- Throws:
IOException
-
readFixed64
Reads and returns the next field of typeFIXED64
and advances the reader to the next field.- Throws:
IOException
-
readFixed32
Reads and returns the next field of typeFIXED32
and advances the reader to the next field.- Throws:
IOException
-
readBool
Reads and returns the next field of typeBOOL
and advances the reader to the next field.- Throws:
IOException
-
readString
Reads and returns the next field of typeSTRING
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
Reads and returns the next field of typeSTRING
and advances the reader to the next field. If the stream contains malformed UTF-8, throw exceptionInvalidProtocolBufferException
.- Throws:
IOException
-
readMessageBySchemaWithCheck
<T> T readMessageBySchemaWithCheck(Schema<T> schema, ExtensionRegistryLite extensionRegistry) throws IOException - Throws:
IOException
-
readMessage
Reads and returns the next field of typeMESSAGE
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 typeGROUP
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
Reads and returns the next field of typeBYTES
and advances the reader to the next field.- Throws:
IOException
-
readUInt32
Reads and returns the next field of typeUINT32
and advances the reader to the next field.- Throws:
IOException
-
readEnum
Reads and returns the next field of typeENUM
and advances the reader to the next field.- Throws:
IOException
-
readSFixed32
Reads and returns the next field of typeSFIXED32
and advances the reader to the next field.- Throws:
IOException
-
readSFixed64
Reads and returns the next field of typeSFIXED64
and advances the reader to the next field.- Throws:
IOException
-
readSInt32
Reads and returns the next field of typeSINT32
and advances the reader to the next field.- Throws:
IOException
-
readSInt64
Reads and returns the next field of typeSINT64
and advances the reader to the next field.- Throws:
IOException
-
readDoubleList
Reads the next field of typeDOUBLE_LIST
orDOUBLE_LIST_PACKED
and advances the reader to the next field.- Parameters:
target
- the list that will receive the read values.- Throws:
IOException
-
readFloatList
Reads the next field of typeFLOAT_LIST
orFLOAT_LIST_PACKED
and advances the reader to the next field.- Parameters:
target
- the list that will receive the read values.- Throws:
IOException
-
readUInt64List
Reads the next field of typeUINT64_LIST
orUINT64_LIST_PACKED
and advances the reader to the next field.- Parameters:
target
- the list that will receive the read values.- Throws:
IOException
-
readInt64List
Reads the next field of typeINT64_LIST
orINT64_LIST_PACKED
and advances the reader to the next field.- Parameters:
target
- the list that will receive the read values.- Throws:
IOException
-
readInt32List
Reads the next field of typeINT32_LIST
orINT32_LIST_PACKED
and advances the reader to the next field.- Parameters:
target
- the list that will receive the read values.- Throws:
IOException
-
readFixed64List
Reads the next field of typeFIXED64_LIST
orFIXED64_LIST_PACKED
and advances the reader to the next field.- Parameters:
target
- the list that will receive the read values.- Throws:
IOException
-
readFixed32List
Reads the next field of typeFIXED32_LIST
orFIXED32_LIST_PACKED
and advances the reader to the next field.- Parameters:
target
- the list that will receive the read values.- Throws:
IOException
-
readBoolList
Reads the next field of typeBOOL_LIST
orBOOL_LIST_PACKED
and advances the reader to the next field.- Parameters:
target
- the list that will receive the read values.- Throws:
IOException
-
readStringList
Reads the next field of typeSTRING_LIST
and advances the reader to the next field.- Parameters:
target
- the list that will receive the read values.- Throws:
IOException
-
readStringListRequireUtf8
Reads the next field of typeSTRING_LIST
and advances the reader to the next field. If the stream contains malformed UTF-8, throw exceptionInvalidProtocolBufferException
.- 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 typeMESSAGE_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 thetarget
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 typeGROUP_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 thetarget
list.- Throws:
IOException
-
readGroupList
@Deprecated <T> void readGroupList(List<T> target, Schema<T> targetType, ExtensionRegistryLite extensionRegistry) throws IOException Deprecated.- Throws:
IOException
-
readBytesList
Reads the next field of typeBYTES_LIST
and advances the reader to the next field.- Parameters:
target
- the list that will receive the read values.- Throws:
IOException
-
readUInt32List
Reads the next field of typeUINT32_LIST
orUINT32_LIST_PACKED
and advances the reader to the next field.- Parameters:
target
- the list that will receive the read values.- Throws:
IOException
-
readEnumList
Reads the next field of typeENUM_LIST
orENUM_LIST_PACKED
and advances the reader to the next field.- Parameters:
target
- the list that will receive the read values.- Throws:
IOException
-
readSFixed32List
Reads the next field of typeSFIXED32_LIST
orSFIXED32_LIST_PACKED
and advances the reader to the next field.- Parameters:
target
- the list that will receive the read values.- Throws:
IOException
-
readSFixed64List
Reads the next field of typeSFIXED64_LIST
orSFIXED64_LIST_PACKED
and advances the reader to the next field.- Parameters:
target
- the list that will receive the read values.- Throws:
IOException
-
readSInt32List
Reads the next field of typeSINT32_LIST
orSINT32_LIST_PACKED
and advances the reader to the next field.- Parameters:
target
- the list that will receive the read values.- Throws:
IOException
-
readSInt64List
Reads the next field of typeSINT64_LIST
orSINT64_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, throws IOExceptionV> mapDefaultEntry, ExtensionRegistryLite extensionRegistry) Reads the next field of typeMAP
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
-