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 intprivate static final intprivate static final intprivate final CodedInputStreamprivate static final intprivate intprivate intFields inherited from interface com.google.protobuf.Reader
READ_DONE, TAG_UNKNOWN -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic CodedInputStreamReaderforCodedInput(CodedInputStream input) intGets the field number for the current field being read.intgetTag()Gets the wire tag of the current field.<T> voidmergeGroupField(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> voidmergeGroupFieldInternal(T target, Schema<T> schema, ExtensionRegistryLite extensionRegistry) <T> voidmergeMessageField(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> voidmergeMessageFieldInternal(T target, Schema<T> schema, ExtensionRegistryLite extensionRegistry) booleanreadBool()Reads and returns the next field of typeBOOLand advances the reader to the next field.voidreadBoolList(List<Boolean> target) Reads the next field of typeBOOL_LISTorBOOL_LIST_PACKEDand advances the reader to the next field.Reads and returns the next field of typeBYTESand advances the reader to the next field.voidreadBytesList(List<ByteString> target) Reads the next field of typeBYTES_LISTand advances the reader to the next field.doubleReads and returns the next field of typeDOUBLEand advances the reader to the next field.voidreadDoubleList(List<Double> target) Reads the next field of typeDOUBLE_LISTorDOUBLE_LIST_PACKEDand advances the reader to the next field.intreadEnum()Reads and returns the next field of typeENUMand advances the reader to the next field.voidreadEnumList(List<Integer> target) Reads the next field of typeENUM_LISTorENUM_LIST_PACKEDand advances the reader to the next field.private ObjectreadField(WireFormat.FieldType fieldType, Class<?> messageType, ExtensionRegistryLite extensionRegistry) intReads and returns the next field of typeFIXED32and advances the reader to the next field.voidreadFixed32List(List<Integer> target) Reads the next field of typeFIXED32_LISTorFIXED32_LIST_PACKEDand advances the reader to the next field.longReads and returns the next field of typeFIXED64and advances the reader to the next field.voidreadFixed64List(List<Long> target) Reads the next field of typeFIXED64_LISTorFIXED64_LIST_PACKEDand advances the reader to the next field.floatReads and returns the next field of typeFLOATand advances the reader to the next field.voidreadFloatList(List<Float> target) Reads the next field of typeFLOAT_LISTorFLOAT_LIST_PACKEDand advances the reader to the next field.private <T> TreadGroup(Schema<T> schema, ExtensionRegistryLite extensionRegistry) <T> TreadGroup(Class<T> clazz, ExtensionRegistryLite extensionRegistry) Deprecated.<T> TreadGroupBySchemaWithCheck(Schema<T> schema, ExtensionRegistryLite extensionRegistry) Deprecated.<T> voidreadGroupList(List<T> target, Schema<T> schema, ExtensionRegistryLite extensionRegistry) Deprecated.<T> voidreadGroupList(List<T> target, Class<T> targetType, ExtensionRegistryLite extensionRegistry) Deprecated.intReads and returns the next field of typeINT32and advances the reader to the next field.voidreadInt32List(List<Integer> target) Reads the next field of typeINT32_LISTorINT32_LIST_PACKEDand advances the reader to the next field.longReads and returns the next field of typeINT64and advances the reader to the next field.voidreadInt64List(List<Long> target) Reads the next field of typeINT64_LISTorINT64_LIST_PACKEDand 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 typeMAPand advances the reader to the next field.private <T> TreadMessage(Schema<T> schema, ExtensionRegistryLite extensionRegistry) <T> TreadMessage(Class<T> clazz, ExtensionRegistryLite extensionRegistry) Reads and returns the next field of typeMESSAGEand advances the reader to the next field.<T> TreadMessageBySchemaWithCheck(Schema<T> schema, ExtensionRegistryLite extensionRegistry) <T> voidreadMessageList(List<T> target, Schema<T> schema, ExtensionRegistryLite extensionRegistry) Reads the next field of typeMESSAGE_LISTand advances the reader to the next field.<T> voidreadMessageList(List<T> target, Class<T> targetType, ExtensionRegistryLite extensionRegistry) intReads and returns the next field of typeSFIXED32and advances the reader to the next field.voidreadSFixed32List(List<Integer> target) Reads the next field of typeSFIXED32_LISTorSFIXED32_LIST_PACKEDand advances the reader to the next field.longReads and returns the next field of typeSFIXED64and advances the reader to the next field.voidreadSFixed64List(List<Long> target) Reads the next field of typeSFIXED64_LISTorSFIXED64_LIST_PACKEDand advances the reader to the next field.intReads and returns the next field of typeSINT32and advances the reader to the next field.voidreadSInt32List(List<Integer> target) Reads the next field of typeSINT32_LISTorSINT32_LIST_PACKEDand advances the reader to the next field.longReads and returns the next field of typeSINT64and advances the reader to the next field.voidreadSInt64List(List<Long> target) Reads the next field of typeSINT64_LISTorSINT64_LIST_PACKEDand advances the reader to the next field.Reads and returns the next field of typeSTRINGand advances the reader to the next field.voidreadStringList(List<String> target) Reads the next field of typeSTRING_LISTand advances the reader to the next field.voidreadStringListInternal(List<String> target, boolean requireUtf8) voidreadStringListRequireUtf8(List<String> target) Reads the next field of typeSTRING_LISTand advances the reader to the next field.Reads and returns the next field of typeSTRINGand advances the reader to the next field.intReads and returns the next field of typeUINT32and advances the reader to the next field.voidreadUInt32List(List<Integer> target) Reads the next field of typeUINT32_LISTorUINT32_LIST_PACKEDand advances the reader to the next field.longReads and returns the next field of typeUINT64and advances the reader to the next field.voidreadUInt64List(List<Long> target) Reads the next field of typeUINT64_LISTorUINT64_LIST_PACKEDand advances the reader to the next field.private voidrequirePosition(int expectedPosition) private voidrequireWireType(int requiredWireType) booleanbooleanSkips the current field and advances the reader to the next field.private voidverifyPackedFixed32Length(int bytes) private voidverifyPackedFixed64Length(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:
shouldDiscardUnknownFieldsin interfaceReader
-
getFieldNumber
Description copied from interface:ReaderGets 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:
getFieldNumberin interfaceReader- Returns:
- the current field number or
Reader.READ_DONEif the end of input has been reached. - Throws:
IOException
-
getTag
public int getTag()Description copied from interface:ReaderGets the wire tag of the current field.- Specified by:
getTagin interfaceReader- Returns:
- the current wire tag or
Reader.TAG_UNKNOWNif the reader does not know the tag of the current field.
-
skipField
Description copied from interface:ReaderSkips the current field and advances the reader to the next field.- Specified by:
skipFieldin interfaceReader- Returns:
trueif there are more fields orfalseif the end of input has been reached.- Throws:
IOException
-
requireWireType
- Throws:
IOException
-
readDouble
Description copied from interface:ReaderReads and returns the next field of typeDOUBLEand advances the reader to the next field.- Specified by:
readDoublein interfaceReader- Throws:
IOException
-
readFloat
Description copied from interface:ReaderReads and returns the next field of typeFLOATand advances the reader to the next field.- Specified by:
readFloatin interfaceReader- Throws:
IOException
-
readUInt64
Description copied from interface:ReaderReads and returns the next field of typeUINT64and advances the reader to the next field.- Specified by:
readUInt64in interfaceReader- Throws:
IOException
-
readInt64
Description copied from interface:ReaderReads and returns the next field of typeINT64and advances the reader to the next field.- Specified by:
readInt64in interfaceReader- Throws:
IOException
-
readInt32
Description copied from interface:ReaderReads and returns the next field of typeINT32and advances the reader to the next field.- Specified by:
readInt32in interfaceReader- Throws:
IOException
-
readFixed64
Description copied from interface:ReaderReads and returns the next field of typeFIXED64and advances the reader to the next field.- Specified by:
readFixed64in interfaceReader- Throws:
IOException
-
readFixed32
Description copied from interface:ReaderReads and returns the next field of typeFIXED32and advances the reader to the next field.- Specified by:
readFixed32in interfaceReader- Throws:
IOException
-
readBool
Description copied from interface:ReaderReads and returns the next field of typeBOOLand advances the reader to the next field.- Specified by:
readBoolin interfaceReader- Throws:
IOException
-
readString
Description copied from interface:ReaderReads and returns the next field of typeSTRINGand 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:
readStringin interfaceReader- Throws:
IOException
-
readStringRequireUtf8
Description copied from interface:ReaderReads and returns the next field of typeSTRINGand advances the reader to the next field. If the stream contains malformed UTF-8, throw exceptionInvalidProtocolBufferException.- Specified by:
readStringRequireUtf8in interfaceReader- Throws:
IOException
-
readMessage
public <T> T readMessage(Class<T> clazz, ExtensionRegistryLite extensionRegistry) throws IOException Description copied from interface:ReaderReads and returns the next field of typeMESSAGEand advances the reader to the next field.- Specified by:
readMessagein interfaceReader- Throws:
IOException
-
readMessageBySchemaWithCheck
public <T> T readMessageBySchemaWithCheck(Schema<T> schema, ExtensionRegistryLite extensionRegistry) throws IOException - Specified by:
readMessageBySchemaWithCheckin interfaceReader- Throws:
IOException
-
readGroup
@Deprecated public <T> T readGroup(Class<T> clazz, ExtensionRegistryLite extensionRegistry) throws IOException Deprecated.Description copied from interface:ReaderReads and returns the next field of typeGROUPand advances the reader to the next field.- Specified by:
readGroupin interfaceReader- Throws:
IOException
-
readGroupBySchemaWithCheck
@Deprecated public <T> T readGroupBySchemaWithCheck(Schema<T> schema, ExtensionRegistryLite extensionRegistry) throws IOException Deprecated.- Specified by:
readGroupBySchemaWithCheckin interfaceReader- Throws:
IOException
-
mergeMessageField
public <T> void mergeMessageField(T target, Schema<T> schema, ExtensionRegistryLite extensionRegistry) throws IOException Description copied from interface:ReaderRead a message field from the wire format and merge the results into the given target.- Specified by:
mergeMessageFieldin 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:ReaderRead a group field from the wire format and merge the results into the given target.- Specified by:
mergeGroupFieldin 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:ReaderReads and returns the next field of typeBYTESand advances the reader to the next field.- Specified by:
readBytesin interfaceReader- Throws:
IOException
-
readUInt32
Description copied from interface:ReaderReads and returns the next field of typeUINT32and advances the reader to the next field.- Specified by:
readUInt32in interfaceReader- Throws:
IOException
-
readEnum
Description copied from interface:ReaderReads and returns the next field of typeENUMand advances the reader to the next field.- Specified by:
readEnumin interfaceReader- Throws:
IOException
-
readSFixed32
Description copied from interface:ReaderReads and returns the next field of typeSFIXED32and advances the reader to the next field.- Specified by:
readSFixed32in interfaceReader- Throws:
IOException
-
readSFixed64
Description copied from interface:ReaderReads and returns the next field of typeSFIXED64and advances the reader to the next field.- Specified by:
readSFixed64in interfaceReader- Throws:
IOException
-
readSInt32
Description copied from interface:ReaderReads and returns the next field of typeSINT32and advances the reader to the next field.- Specified by:
readSInt32in interfaceReader- Throws:
IOException
-
readSInt64
Description copied from interface:ReaderReads and returns the next field of typeSINT64and advances the reader to the next field.- Specified by:
readSInt64in interfaceReader- Throws:
IOException
-
readDoubleList
Description copied from interface:ReaderReads the next field of typeDOUBLE_LISTorDOUBLE_LIST_PACKEDand advances the reader to the next field.- Specified by:
readDoubleListin interfaceReader- Parameters:
target- the list that will receive the read values.- Throws:
IOException
-
readFloatList
Description copied from interface:ReaderReads the next field of typeFLOAT_LISTorFLOAT_LIST_PACKEDand advances the reader to the next field.- Specified by:
readFloatListin interfaceReader- Parameters:
target- the list that will receive the read values.- Throws:
IOException
-
readUInt64List
Description copied from interface:ReaderReads the next field of typeUINT64_LISTorUINT64_LIST_PACKEDand advances the reader to the next field.- Specified by:
readUInt64Listin interfaceReader- Parameters:
target- the list that will receive the read values.- Throws:
IOException
-
readInt64List
Description copied from interface:ReaderReads the next field of typeINT64_LISTorINT64_LIST_PACKEDand advances the reader to the next field.- Specified by:
readInt64Listin interfaceReader- Parameters:
target- the list that will receive the read values.- Throws:
IOException
-
readInt32List
Description copied from interface:ReaderReads the next field of typeINT32_LISTorINT32_LIST_PACKEDand advances the reader to the next field.- Specified by:
readInt32Listin interfaceReader- Parameters:
target- the list that will receive the read values.- Throws:
IOException
-
readFixed64List
Description copied from interface:ReaderReads the next field of typeFIXED64_LISTorFIXED64_LIST_PACKEDand advances the reader to the next field.- Specified by:
readFixed64Listin interfaceReader- Parameters:
target- the list that will receive the read values.- Throws:
IOException
-
readFixed32List
Description copied from interface:ReaderReads the next field of typeFIXED32_LISTorFIXED32_LIST_PACKEDand advances the reader to the next field.- Specified by:
readFixed32Listin interfaceReader- Parameters:
target- the list that will receive the read values.- Throws:
IOException
-
readBoolList
Description copied from interface:ReaderReads the next field of typeBOOL_LISTorBOOL_LIST_PACKEDand advances the reader to the next field.- Specified by:
readBoolListin interfaceReader- Parameters:
target- the list that will receive the read values.- Throws:
IOException
-
readStringList
Description copied from interface:ReaderReads the next field of typeSTRING_LISTand advances the reader to the next field.- Specified by:
readStringListin interfaceReader- Parameters:
target- the list that will receive the read values.- Throws:
IOException
-
readStringListRequireUtf8
Description copied from interface:ReaderReads the next field of typeSTRING_LISTand advances the reader to the next field. If the stream contains malformed UTF-8, throw exceptionInvalidProtocolBufferException.- Specified by:
readStringListRequireUtf8in 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:
readMessageListin interfaceReader- Throws:
IOException
-
readMessageList
public <T> void readMessageList(List<T> target, Schema<T> schema, ExtensionRegistryLite extensionRegistry) throws IOException Description copied from interface:ReaderReads the next field of typeMESSAGE_LISTand advances the reader to the next field.- Specified by:
readMessageListin 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:ReaderReads the next field of typeGROUP_LISTand advances the reader to the next field.- Specified by:
readGroupListin interfaceReader- Parameters:
target- the list that will receive the read values.targetType- the type of the elements stored in thetargetlist.- Throws:
IOException
-
readGroupList
@Deprecated public <T> void readGroupList(List<T> target, Schema<T> schema, ExtensionRegistryLite extensionRegistry) throws IOException Deprecated.- Specified by:
readGroupListin interfaceReader- Throws:
IOException
-
readBytesList
Description copied from interface:ReaderReads the next field of typeBYTES_LISTand advances the reader to the next field.- Specified by:
readBytesListin interfaceReader- Parameters:
target- the list that will receive the read values.- Throws:
IOException
-
readUInt32List
Description copied from interface:ReaderReads the next field of typeUINT32_LISTorUINT32_LIST_PACKEDand advances the reader to the next field.- Specified by:
readUInt32Listin interfaceReader- Parameters:
target- the list that will receive the read values.- Throws:
IOException
-
readEnumList
Description copied from interface:ReaderReads the next field of typeENUM_LISTorENUM_LIST_PACKEDand advances the reader to the next field.- Specified by:
readEnumListin interfaceReader- Parameters:
target- the list that will receive the read values.- Throws:
IOException
-
readSFixed32List
Description copied from interface:ReaderReads the next field of typeSFIXED32_LISTorSFIXED32_LIST_PACKEDand advances the reader to the next field.- Specified by:
readSFixed32Listin interfaceReader- Parameters:
target- the list that will receive the read values.- Throws:
IOException
-
readSFixed64List
Description copied from interface:ReaderReads the next field of typeSFIXED64_LISTorSFIXED64_LIST_PACKEDand advances the reader to the next field.- Specified by:
readSFixed64Listin interfaceReader- Parameters:
target- the list that will receive the read values.- Throws:
IOException
-
readSInt32List
Description copied from interface:ReaderReads the next field of typeSINT32_LISTorSINT32_LIST_PACKEDand advances the reader to the next field.- Specified by:
readSInt32Listin interfaceReader- Parameters:
target- the list that will receive the read values.- Throws:
IOException
-
readSInt64List
Description copied from interface:ReaderReads the next field of typeSINT64_LISTorSINT64_LIST_PACKEDand advances the reader to the next field.- Specified by:
readSInt64Listin 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:ReaderReads the next field of typeMAPand advances the reader to the next field.- Specified by:
readMapin 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
-