Package com.google.protobuf
Class UnknownFieldSet
- java.lang.Object
-
- com.google.protobuf.UnknownFieldSet
-
- All Implemented Interfaces:
MessageLite,MessageLiteOrBuilder
public final class UnknownFieldSet extends java.lang.Object implements MessageLite
UnknownFieldSetkeeps 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
Messagecontains anUnknownFieldSet(and everyMessage.Buildercontains aUnknownFieldSet.Builder).Most users will never need to use this class.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classUnknownFieldSet.BuilderBuilder forUnknownFieldSets.static classUnknownFieldSet.FieldRepresents a single field in anUnknownFieldSet.static classUnknownFieldSet.ParserParser to implement MessageLite interface.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map<java.lang.Integer,UnknownFieldSet.Field>asMap()Get a map of fields in the set by number.booleanequals(java.lang.Object other)static UnknownFieldSetgetDefaultInstance()Get an emptyUnknownFieldSet.UnknownFieldSetgetDefaultInstanceForType()Get an instance of the type with no fields set.UnknownFieldSet.FieldgetField(int number)Get a field by number.UnknownFieldSet.ParsergetParserForType()Gets the parser for a message of the same type as this message.intgetSerializedSize()Get the number of bytes required to encode this set.intgetSerializedSizeAsMessageSet()Get 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()booleanisInitialized()Returns true if all required fields in the message and all embedded messages are set, false otherwise.static UnknownFieldSet.BuildernewBuilder()Create a newUnknownFieldSet.Builder.static UnknownFieldSet.BuildernewBuilder(UnknownFieldSet copyFrom)Create a newUnknownFieldSet.Builderand initialize it to be a copy ofcopyFrom.UnknownFieldSet.BuildernewBuilderForType()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(java.io.InputStream input)Parse anUnknownFieldSetfrominputand return it.UnknownFieldSet.BuildertoBuilder()Constructs a builder initialized with the current message.byte[]toByteArray()Serializes the message to abytearray and returns it.ByteStringtoByteString()Serializes the message to aByteStringand returns it.java.lang.StringtoString()Converts the set to a string in protocol buffer text format.voidwriteAsMessageSetTo(CodedOutputStream output)Serializes the set and writes it tooutputusingMessageSetwire format.voidwriteDelimitedTo(java.io.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.voidwriteTo(java.io.OutputStream output)Serializes the message and writes it tooutput.
-
-
-
Method Detail
-
newBuilder
public static UnknownFieldSet.Builder newBuilder()
Create a newUnknownFieldSet.Builder.
-
newBuilder
public static UnknownFieldSet.Builder newBuilder(UnknownFieldSet copyFrom)
Create a newUnknownFieldSet.Builderand initialize it to be a copy ofcopyFrom.
-
getDefaultInstance
public static UnknownFieldSet getDefaultInstance()
Get an emptyUnknownFieldSet.
-
getDefaultInstanceForType
public UnknownFieldSet 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
public boolean equals(java.lang.Object other)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
asMap
public java.util.Map<java.lang.Integer,UnknownFieldSet.Field> 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
public UnknownFieldSet.Field getField(int number)
Get a field by number. Returns an empty field if not present. Never returnsnull.
-
writeTo
public void writeTo(CodedOutputStream output) throws java.io.IOException
Serializes the set and writes it tooutput.- Specified by:
writeToin interfaceMessageLite- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
Converts the set to a string in protocol buffer text format. This is just a trivial wrapper aroundTextFormat.Printer.printToString(UnknownFieldSet).- Overrides:
toStringin classjava.lang.Object
-
toByteString
public ByteString 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
public void writeTo(java.io.OutputStream output) throws java.io.IOExceptionSerializes the message and writes it tooutput. This is just a trivial wrapper aroundwriteTo(CodedOutputStream).- Specified by:
writeToin interfaceMessageLite- Throws:
java.io.IOException
-
writeDelimitedTo
public void writeDelimitedTo(java.io.OutputStream output) throws java.io.IOExceptionDescription 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:
java.io.IOException
-
getSerializedSize
public int getSerializedSize()
Get the number of bytes required to encode this set.- Specified by:
getSerializedSizein interfaceMessageLite
-
writeAsMessageSetTo
public void writeAsMessageSetTo(CodedOutputStream output) throws java.io.IOException
Serializes the set and writes it tooutputusingMessageSetwire format.- Throws:
java.io.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
public static UnknownFieldSet parseFrom(CodedInputStream input) throws java.io.IOException
Parse anUnknownFieldSetfrom the given input stream.- Throws:
java.io.IOException
-
parseFrom
public static UnknownFieldSet parseFrom(ByteString data) throws InvalidProtocolBufferException
Parsedataas anUnknownFieldSetand return it.- Throws:
InvalidProtocolBufferException
-
parseFrom
public static UnknownFieldSet parseFrom(byte[] data) throws InvalidProtocolBufferException
Parsedataas anUnknownFieldSetand return it.- Throws:
InvalidProtocolBufferException
-
parseFrom
public static UnknownFieldSet parseFrom(java.io.InputStream input) throws java.io.IOException
Parse anUnknownFieldSetfrominputand return it.- Throws:
java.io.IOException
-
newBuilderForType
public UnknownFieldSet.Builder newBuilderForType()
Description copied from interface:MessageLiteConstructs a new builder for a message of the same type as this message.- Specified by:
newBuilderForTypein interfaceMessageLite
-
toBuilder
public UnknownFieldSet.Builder 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
public final UnknownFieldSet.Parser getParserForType()
Description copied from interface:MessageLiteGets the parser for a message of the same type as this message.- Specified by:
getParserForTypein interfaceMessageLite
-
-