Package com.google.protobuf
Class UnknownFieldSet
java.lang.Object
com.google.protobuf.UnknownFieldSet
- All Implemented Interfaces:
MessageLite,MessageLiteOrBuilder
UnknownFieldSet keeps track of fields which were seen when parsing a protocol
message but whose field numbers or types are unrecognized. This most frequently occurs when new
fields are added to a message type and then messages containing those fields are read by old
software that was compiled before the new types were added.
Every Message contains an UnknownFieldSet (and every Message.Builder
contains a UnknownFieldSet.Builder).
Most users will never need to use this class.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder forUnknownFieldSets.static final classRepresents a single field in anUnknownFieldSet.static final classParser to implement MessageLite interface. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final UnknownFieldSetprivate final TreeMap<Integer,UnknownFieldSet.Field> private static final UnknownFieldSet.Parser -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateConstruct anUnknownFieldSetaround the given map. -
Method Summary
Modifier and TypeMethodDescriptionasMap()Get a map of fields in the set by number.booleanstatic UnknownFieldSetGet an emptyUnknownFieldSet.Get an instance of the type with no fields set.getField(int number) Get a field by number.final UnknownFieldSet.ParserGets the parser for a message of the same type as this message.intGet the number of bytes required to encode this set.intGet the number of bytes required to encode this set usingMessageSetwire format.booleanhasField(int number) Check if the given field number is present in the set.inthashCode()booleanReturns true if all required fields in the message and all embedded messages are set, false otherwise.static UnknownFieldSet.BuilderCreate a newUnknownFieldSet.Builder.static UnknownFieldSet.BuildernewBuilder(UnknownFieldSet copyFrom) Create a newUnknownFieldSet.Builderand initialize it to be a copy ofcopyFrom.Constructs a new builder for a message of the same type as this message.static UnknownFieldSetparseFrom(byte[] data) Parsedataas anUnknownFieldSetand return it.static UnknownFieldSetparseFrom(ByteString data) Parsedataas anUnknownFieldSetand return it.static UnknownFieldSetparseFrom(CodedInputStream input) Parse anUnknownFieldSetfrom the given input stream.static UnknownFieldSetparseFrom(InputStream input) Parse anUnknownFieldSetfrominputand return it.Constructs a builder initialized with the current message.byte[]Serializes the message to abytearray and returns it.Serializes the message to aByteStringand returns it.toString()Converts the set to a string in protocol buffer text format.voidwriteAsMessageSetTo(CodedOutputStream output) Serializes the set and writes it tooutputusingMessageSetwire format.(package private) voidwriteAsMessageSetTo(Writer writer) Serializes the set and writes it towriterusingMessageSetwire format.voidwriteDelimitedTo(OutputStream output) LikeMessageLite.writeTo(OutputStream), but writes the size of the message as a varint before writing the data.voidwriteTo(CodedOutputStream output) Serializes the set and writes it tooutput.(package private) voidSerializes the set and writes it towriter.voidwriteTo(OutputStream output) Serializes the message and writes it tooutput.
-
Field Details
-
fields
-
defaultInstance
-
PARSER
-
-
Constructor Details
-
UnknownFieldSet
Construct anUnknownFieldSetaround the given map.
-
-
Method Details
-
newBuilder
Create a newUnknownFieldSet.Builder. -
newBuilder
Create a newUnknownFieldSet.Builderand initialize it to be a copy ofcopyFrom. -
getDefaultInstance
Get an emptyUnknownFieldSet. -
getDefaultInstanceForType
Description copied from interface:MessageLiteOrBuilderGet an instance of the type with no fields set. Because no fields are set, all getters for singular fields will return default values and repeated fields will appear empty. This may or may not be a singleton. This differs from thegetDefaultInstance()method of generated message classes in that this method is an abstract method of theMessageLiteinterface whereasgetDefaultInstance()is a static method of a specific class. They return the same thing.- Specified by:
getDefaultInstanceForTypein interfaceMessageLiteOrBuilder
-
equals
-
hashCode
public int hashCode() -
asMap
Get a map of fields in the set by number. -
hasField
public boolean hasField(int number) Check if the given field number is present in the set. -
getField
Get a field by number. Returns an empty field if not present. Never returnsnull. -
writeTo
Serializes the set and writes it tooutput.- Specified by:
writeToin interfaceMessageLite- Throws:
IOException
-
toString
Converts the set to a string in protocol buffer text format. This is just a trivial wrapper aroundTextFormat.Printer.printToString(UnknownFieldSet). -
toByteString
Serializes the message to aByteStringand returns it. This is just a trivial wrapper aroundwriteTo(CodedOutputStream).- Specified by:
toByteStringin interfaceMessageLite
-
toByteArray
public byte[] toByteArray()Serializes the message to abytearray and returns it. This is just a trivial wrapper aroundwriteTo(CodedOutputStream).- Specified by:
toByteArrayin interfaceMessageLite
-
writeTo
Serializes the message and writes it tooutput. This is just a trivial wrapper aroundwriteTo(CodedOutputStream).- Specified by:
writeToin interfaceMessageLite- Throws:
IOException
-
writeDelimitedTo
Description copied from interface:MessageLiteLikeMessageLite.writeTo(OutputStream), but writes the size of the message as a varint before writing the data. This allows more data to be written to the stream after the message without the need to delimit the message data yourself. UseMessageLite.Builder.mergeDelimitedFrom(InputStream)(or the static methodYourMessageType.parseDelimitedFrom(InputStream)) to parse messages written by this method.- Specified by:
writeDelimitedToin interfaceMessageLite- Throws:
IOException
-
getSerializedSize
public int getSerializedSize()Get the number of bytes required to encode this set.- Specified by:
getSerializedSizein interfaceMessageLite
-
writeAsMessageSetTo
Serializes the set and writes it tooutputusingMessageSetwire format.- Throws:
IOException
-
writeTo
Serializes the set and writes it towriter.- Throws:
IOException
-
writeAsMessageSetTo
Serializes the set and writes it towriterusingMessageSetwire format.- Throws:
IOException
-
getSerializedSizeAsMessageSet
public int getSerializedSizeAsMessageSet()Get the number of bytes required to encode this set usingMessageSetwire format. -
isInitialized
public boolean isInitialized()Description copied from interface:MessageLiteOrBuilderReturns true if all required fields in the message and all embedded messages are set, false otherwise.- Specified by:
isInitializedin interfaceMessageLiteOrBuilder
-
parseFrom
Parse anUnknownFieldSetfrom the given input stream.- Throws:
IOException
-
parseFrom
Parsedataas anUnknownFieldSetand return it.- Throws:
InvalidProtocolBufferException
-
parseFrom
Parsedataas anUnknownFieldSetand return it.- Throws:
InvalidProtocolBufferException
-
parseFrom
Parse anUnknownFieldSetfrominputand return it.- Throws:
IOException
-
newBuilderForType
Description copied from interface:MessageLiteConstructs a new builder for a message of the same type as this message.- Specified by:
newBuilderForTypein interfaceMessageLite
-
toBuilder
Description copied from interface:MessageLiteConstructs a builder initialized with the current message. Use this to derive a new message from the current one.- Specified by:
toBuilderin interfaceMessageLite
-
getParserForType
Description copied from interface:MessageLiteGets the parser for a message of the same type as this message.- Specified by:
getParserForTypein interfaceMessageLite
-