Package com.google.protobuf
Class CodedInputStreamReader
java.lang.Object
com.google.protobuf.CodedInputStreamReader
- All Implemented Interfaces:
Reader
@CheckReturnValue
@ExperimentalApi
final class CodedInputStreamReader
extends Object
implements Reader
An adapter between the
Reader
interface and CodedInputStream
.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
private static final int
private static final int
private final CodedInputStream
private static final int
private int
private int
Fields inherited from interface com.google.protobuf.Reader
READ_DONE, TAG_UNKNOWN
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic CodedInputStreamReader
forCodedInput
(CodedInputStream input) int
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.private <T> void
mergeGroupFieldInternal
(T target, Schema<T> schema, ExtensionRegistryLite extensionRegistry) <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.private <T> void
mergeMessageFieldInternal
(T target, Schema<T> schema, ExtensionRegistryLite extensionRegistry) 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.private Object
readField
(WireFormat.FieldType fieldType, Class<?> messageType, ExtensionRegistryLite extensionRegistry) 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.private <T> T
readGroup
(Schema<T> schema, ExtensionRegistryLite extensionRegistry) <T> T
readGroup
(Class<T> clazz, ExtensionRegistryLite extensionRegistry) Deprecated.<T> T
readGroupBySchemaWithCheck
(Schema<T> schema, ExtensionRegistryLite extensionRegistry) Deprecated.<T> void
readGroupList
(List<T> target, Schema<T> schema, ExtensionRegistryLite extensionRegistry) Deprecated.<T> void
readGroupList
(List<T> target, Class<T> targetType, ExtensionRegistryLite extensionRegistry) 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> metadata, ExtensionRegistryLite extensionRegistry) Reads the next field of typeMAP
and advances the reader to the next field.private <T> T
readMessage
(Schema<T> schema, ExtensionRegistryLite extensionRegistry) <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
readStringListInternal
(List<String> target, boolean requireUtf8) 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.private void
requirePosition
(int expectedPosition) private void
requireWireType
(int requiredWireType) boolean
boolean
Skips the current field and advances the reader to the next field.private void
verifyPackedFixed32Length
(int bytes) private void
verifyPackedFixed64Length
(int bytes)
-
Field Details
-
FIXED32_MULTIPLE_MASK
private static final int FIXED32_MULTIPLE_MASK- See Also:
-
FIXED64_MULTIPLE_MASK
private static final int FIXED64_MULTIPLE_MASK- See Also:
-
NEXT_TAG_UNSET
private static final int NEXT_TAG_UNSET- See Also:
-
input
-
tag
private int tag -
endGroupTag
private int endGroupTag -
nextTag
private int nextTag
-
-
Constructor Details
-
CodedInputStreamReader
-
-
Method Details
-
forCodedInput
-
shouldDiscardUnknownFields
public boolean shouldDiscardUnknownFields()- Specified by:
shouldDiscardUnknownFields
in interfaceReader
-
getFieldNumber
Description copied from interface:Reader
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.
- Specified by:
getFieldNumber
in interfaceReader
- Returns:
- the current field number or
Reader.READ_DONE
if the end of input has been reached. - Throws:
IOException
-
getTag
public int getTag()Description copied from interface:Reader
Gets the wire tag of the current field.- Specified by:
getTag
in interfaceReader
- Returns:
- the current wire tag or
Reader.TAG_UNKNOWN
if the reader does not know the tag of the current field.
-
skipField
Description copied from interface:Reader
Skips the current field and advances the reader to the next field.- Specified by:
skipField
in interfaceReader
- Returns:
true
if there are more fields orfalse
if the end of input has been reached.- Throws:
IOException
-
requireWireType
- Throws:
IOException
-
readDouble
Description copied from interface:Reader
Reads and returns the next field of typeDOUBLE
and advances the reader to the next field.- Specified by:
readDouble
in interfaceReader
- Throws:
IOException
-
readFloat
Description copied from interface:Reader
Reads and returns the next field of typeFLOAT
and advances the reader to the next field.- Specified by:
readFloat
in interfaceReader
- Throws:
IOException
-
readUInt64
Description copied from interface:Reader
Reads and returns the next field of typeUINT64
and advances the reader to the next field.- Specified by:
readUInt64
in interfaceReader
- Throws:
IOException
-
readInt64
Description copied from interface:Reader
Reads and returns the next field of typeINT64
and advances the reader to the next field.- Specified by:
readInt64
in interfaceReader
- Throws:
IOException
-
readInt32
Description copied from interface:Reader
Reads and returns the next field of typeINT32
and advances the reader to the next field.- Specified by:
readInt32
in interfaceReader
- Throws:
IOException
-
readFixed64
Description copied from interface:Reader
Reads and returns the next field of typeFIXED64
and advances the reader to the next field.- Specified by:
readFixed64
in interfaceReader
- Throws:
IOException
-
readFixed32
Description copied from interface:Reader
Reads and returns the next field of typeFIXED32
and advances the reader to the next field.- Specified by:
readFixed32
in interfaceReader
- Throws:
IOException
-
readBool
Description copied from interface:Reader
Reads and returns the next field of typeBOOL
and advances the reader to the next field.- Specified by:
readBool
in interfaceReader
- Throws:
IOException
-
readString
Description copied from interface:Reader
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.- Specified by:
readString
in interfaceReader
- Throws:
IOException
-
readStringRequireUtf8
Description copied from interface:Reader
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
.- Specified by:
readStringRequireUtf8
in interfaceReader
- Throws:
IOException
-
readMessage
public <T> T readMessage(Class<T> clazz, ExtensionRegistryLite extensionRegistry) throws IOException Description copied from interface:Reader
Reads and returns the next field of typeMESSAGE
and advances the reader to the next field.- Specified by:
readMessage
in interfaceReader
- Throws:
IOException
-
readMessageBySchemaWithCheck
public <T> T readMessageBySchemaWithCheck(Schema<T> schema, ExtensionRegistryLite extensionRegistry) throws IOException - Specified by:
readMessageBySchemaWithCheck
in interfaceReader
- Throws:
IOException
-
readGroup
@Deprecated public <T> T readGroup(Class<T> clazz, ExtensionRegistryLite extensionRegistry) throws IOException Deprecated.Description copied from interface:Reader
Reads and returns the next field of typeGROUP
and advances the reader to the next field.- Specified by:
readGroup
in interfaceReader
- Throws:
IOException
-
readGroupBySchemaWithCheck
@Deprecated public <T> T readGroupBySchemaWithCheck(Schema<T> schema, ExtensionRegistryLite extensionRegistry) throws IOException Deprecated.- Specified by:
readGroupBySchemaWithCheck
in interfaceReader
- Throws:
IOException
-
mergeMessageField
public <T> void mergeMessageField(T target, Schema<T> schema, ExtensionRegistryLite extensionRegistry) throws IOException Description copied from interface:Reader
Read a message field from the wire format and merge the results into the given target.- Specified by:
mergeMessageField
in interfaceReader
- Throws:
IOException
-
mergeMessageFieldInternal
private <T> void mergeMessageFieldInternal(T target, Schema<T> schema, ExtensionRegistryLite extensionRegistry) throws IOException - Throws:
IOException
-
readMessage
private <T> T readMessage(Schema<T> schema, ExtensionRegistryLite extensionRegistry) throws IOException - Throws:
IOException
-
mergeGroupField
public <T> void mergeGroupField(T target, Schema<T> schema, ExtensionRegistryLite extensionRegistry) throws IOException Description copied from interface:Reader
Read a group field from the wire format and merge the results into the given target.- Specified by:
mergeGroupField
in interfaceReader
- Throws:
IOException
-
mergeGroupFieldInternal
private <T> void mergeGroupFieldInternal(T target, Schema<T> schema, ExtensionRegistryLite extensionRegistry) throws IOException - Throws:
IOException
-
readGroup
private <T> T readGroup(Schema<T> schema, ExtensionRegistryLite extensionRegistry) throws IOException - Throws:
IOException
-
readBytes
Description copied from interface:Reader
Reads and returns the next field of typeBYTES
and advances the reader to the next field.- Specified by:
readBytes
in interfaceReader
- Throws:
IOException
-
readUInt32
Description copied from interface:Reader
Reads and returns the next field of typeUINT32
and advances the reader to the next field.- Specified by:
readUInt32
in interfaceReader
- Throws:
IOException
-
readEnum
Description copied from interface:Reader
Reads and returns the next field of typeENUM
and advances the reader to the next field.- Specified by:
readEnum
in interfaceReader
- Throws:
IOException
-
readSFixed32
Description copied from interface:Reader
Reads and returns the next field of typeSFIXED32
and advances the reader to the next field.- Specified by:
readSFixed32
in interfaceReader
- Throws:
IOException
-
readSFixed64
Description copied from interface:Reader
Reads and returns the next field of typeSFIXED64
and advances the reader to the next field.- Specified by:
readSFixed64
in interfaceReader
- Throws:
IOException
-
readSInt32
Description copied from interface:Reader
Reads and returns the next field of typeSINT32
and advances the reader to the next field.- Specified by:
readSInt32
in interfaceReader
- Throws:
IOException
-
readSInt64
Description copied from interface:Reader
Reads and returns the next field of typeSINT64
and advances the reader to the next field.- Specified by:
readSInt64
in interfaceReader
- Throws:
IOException
-
readDoubleList
Description copied from interface:Reader
Reads the next field of typeDOUBLE_LIST
orDOUBLE_LIST_PACKED
and advances the reader to the next field.- Specified by:
readDoubleList
in interfaceReader
- Parameters:
target
- the list that will receive the read values.- Throws:
IOException
-
readFloatList
Description copied from interface:Reader
Reads the next field of typeFLOAT_LIST
orFLOAT_LIST_PACKED
and advances the reader to the next field.- Specified by:
readFloatList
in interfaceReader
- Parameters:
target
- the list that will receive the read values.- Throws:
IOException
-
readUInt64List
Description copied from interface:Reader
Reads the next field of typeUINT64_LIST
orUINT64_LIST_PACKED
and advances the reader to the next field.- Specified by:
readUInt64List
in interfaceReader
- Parameters:
target
- the list that will receive the read values.- Throws:
IOException
-
readInt64List
Description copied from interface:Reader
Reads the next field of typeINT64_LIST
orINT64_LIST_PACKED
and advances the reader to the next field.- Specified by:
readInt64List
in interfaceReader
- Parameters:
target
- the list that will receive the read values.- Throws:
IOException
-
readInt32List
Description copied from interface:Reader
Reads the next field of typeINT32_LIST
orINT32_LIST_PACKED
and advances the reader to the next field.- Specified by:
readInt32List
in interfaceReader
- Parameters:
target
- the list that will receive the read values.- Throws:
IOException
-
readFixed64List
Description copied from interface:Reader
Reads the next field of typeFIXED64_LIST
orFIXED64_LIST_PACKED
and advances the reader to the next field.- Specified by:
readFixed64List
in interfaceReader
- Parameters:
target
- the list that will receive the read values.- Throws:
IOException
-
readFixed32List
Description copied from interface:Reader
Reads the next field of typeFIXED32_LIST
orFIXED32_LIST_PACKED
and advances the reader to the next field.- Specified by:
readFixed32List
in interfaceReader
- Parameters:
target
- the list that will receive the read values.- Throws:
IOException
-
readBoolList
Description copied from interface:Reader
Reads the next field of typeBOOL_LIST
orBOOL_LIST_PACKED
and advances the reader to the next field.- Specified by:
readBoolList
in interfaceReader
- Parameters:
target
- the list that will receive the read values.- Throws:
IOException
-
readStringList
Description copied from interface:Reader
Reads the next field of typeSTRING_LIST
and advances the reader to the next field.- Specified by:
readStringList
in interfaceReader
- Parameters:
target
- the list that will receive the read values.- Throws:
IOException
-
readStringListRequireUtf8
Description copied from interface:Reader
Reads the next field of typeSTRING_LIST
and advances the reader to the next field. If the stream contains malformed UTF-8, throw exceptionInvalidProtocolBufferException
.- Specified by:
readStringListRequireUtf8
in interfaceReader
- Parameters:
target
- the list that will receive the read values.- Throws:
IOException
-
readStringListInternal
- Throws:
IOException
-
readMessageList
public <T> void readMessageList(List<T> target, Class<T> targetType, ExtensionRegistryLite extensionRegistry) throws IOException - Specified by:
readMessageList
in interfaceReader
- Throws:
IOException
-
readMessageList
public <T> void readMessageList(List<T> target, Schema<T> schema, ExtensionRegistryLite extensionRegistry) throws IOException Description copied from interface:Reader
Reads the next field of typeMESSAGE_LIST
and advances the reader to the next field.- Specified by:
readMessageList
in interfaceReader
- Parameters:
target
- the list that will receive the read values.- Throws:
IOException
-
readGroupList
@Deprecated public <T> void readGroupList(List<T> target, Class<T> targetType, ExtensionRegistryLite extensionRegistry) throws IOException Deprecated.Description copied from interface:Reader
Reads the next field of typeGROUP_LIST
and advances the reader to the next field.- Specified by:
readGroupList
in interfaceReader
- Parameters:
target
- the list that will receive the read values.targetType
- the type of the elements stored in thetarget
list.- Throws:
IOException
-
readGroupList
@Deprecated public <T> void readGroupList(List<T> target, Schema<T> schema, ExtensionRegistryLite extensionRegistry) throws IOException Deprecated.- Specified by:
readGroupList
in interfaceReader
- Throws:
IOException
-
readBytesList
Description copied from interface:Reader
Reads the next field of typeBYTES_LIST
and advances the reader to the next field.- Specified by:
readBytesList
in interfaceReader
- Parameters:
target
- the list that will receive the read values.- Throws:
IOException
-
readUInt32List
Description copied from interface:Reader
Reads the next field of typeUINT32_LIST
orUINT32_LIST_PACKED
and advances the reader to the next field.- Specified by:
readUInt32List
in interfaceReader
- Parameters:
target
- the list that will receive the read values.- Throws:
IOException
-
readEnumList
Description copied from interface:Reader
Reads the next field of typeENUM_LIST
orENUM_LIST_PACKED
and advances the reader to the next field.- Specified by:
readEnumList
in interfaceReader
- Parameters:
target
- the list that will receive the read values.- Throws:
IOException
-
readSFixed32List
Description copied from interface:Reader
Reads the next field of typeSFIXED32_LIST
orSFIXED32_LIST_PACKED
and advances the reader to the next field.- Specified by:
readSFixed32List
in interfaceReader
- Parameters:
target
- the list that will receive the read values.- Throws:
IOException
-
readSFixed64List
Description copied from interface:Reader
Reads the next field of typeSFIXED64_LIST
orSFIXED64_LIST_PACKED
and advances the reader to the next field.- Specified by:
readSFixed64List
in interfaceReader
- Parameters:
target
- the list that will receive the read values.- Throws:
IOException
-
readSInt32List
Description copied from interface:Reader
Reads the next field of typeSINT32_LIST
orSINT32_LIST_PACKED
and advances the reader to the next field.- Specified by:
readSInt32List
in interfaceReader
- Parameters:
target
- the list that will receive the read values.- Throws:
IOException
-
readSInt64List
Description copied from interface:Reader
Reads the next field of typeSINT64_LIST
orSINT64_LIST_PACKED
and advances the reader to the next field.- Specified by:
readSInt64List
in interfaceReader
- Parameters:
target
- the list that will receive the read values.- Throws:
IOException
-
verifyPackedFixed64Length
- Throws:
IOException
-
readMap
public <K,V> void readMap(Map<K, V> target, MapEntryLite.Metadata<K, throws IOExceptionV> metadata, ExtensionRegistryLite extensionRegistry) Description copied from interface:Reader
Reads the next field of typeMAP
and advances the reader to the next field.- Specified by:
readMap
in interfaceReader
- Parameters:
target
- the mutable map that will receive the read values.metadata
- the default entry of the map field.extensionRegistry
- the extension registry for parsing message value fields.- Throws:
IOException
-
readField
private Object readField(WireFormat.FieldType fieldType, Class<?> messageType, ExtensionRegistryLite extensionRegistry) throws IOException - Throws:
IOException
-
verifyPackedFixed32Length
- Throws:
IOException
-
requirePosition
- Throws:
IOException
-