Package com.google.protobuf
Class UnknownFieldSet
- java.lang.Object
-
- com.google.protobuf.UnknownFieldSet
-
- All Implemented Interfaces:
com.google.protobuf.MessageLite
,com.google.protobuf.MessageLiteOrBuilder
public final class UnknownFieldSet extends java.lang.Object implements com.google.protobuf.MessageLite
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 anUnknownFieldSet
(and everyMessage.Builder
contains aUnknownFieldSet.Builder
).Most users will never need to use this class.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
UnknownFieldSet.Builder
Builder forUnknownFieldSet
s.static class
UnknownFieldSet.Field
Represents a single field in anUnknownFieldSet
.static class
UnknownFieldSet.Parser
Parser 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.boolean
equals(java.lang.Object other)
static UnknownFieldSet
getDefaultInstance()
Get an emptyUnknownFieldSet
.UnknownFieldSet
getDefaultInstanceForType()
UnknownFieldSet.Field
getField(int number)
Get a field by number.UnknownFieldSet.Parser
getParserForType()
int
getSerializedSize()
Get the number of bytes required to encode this set.int
getSerializedSizeAsMessageSet()
Get the number of bytes required to encode this set usingMessageSet
wire format.boolean
hasField(int number)
Check if the given field number is present in the set.int
hashCode()
boolean
isEmpty()
Whether the field set has no fields.boolean
isInitialized()
static UnknownFieldSet.Builder
newBuilder()
Create a newUnknownFieldSet.Builder
.static UnknownFieldSet.Builder
newBuilder(UnknownFieldSet copyFrom)
Create a newUnknownFieldSet.Builder
and initialize it to be a copy ofcopyFrom
.UnknownFieldSet.Builder
newBuilderForType()
static UnknownFieldSet
parseFrom(byte[] data)
Parsedata
as anUnknownFieldSet
and return it.static UnknownFieldSet
parseFrom(com.google.protobuf.ByteString data)
Parsedata
as anUnknownFieldSet
and return it.static UnknownFieldSet
parseFrom(com.google.protobuf.CodedInputStream input)
Parse anUnknownFieldSet
from the given input stream.static UnknownFieldSet
parseFrom(java.io.InputStream input)
Parse anUnknownFieldSet
frominput
and return it.UnknownFieldSet.Builder
toBuilder()
byte[]
toByteArray()
Serializes the message to abyte
array and returns it.com.google.protobuf.ByteString
toByteString()
Serializes the message to aByteString
and returns it.java.lang.String
toString()
Converts the set to a string in protocol buffer text format.void
writeAsMessageSetTo(com.google.protobuf.CodedOutputStream output)
Serializes the set and writes it tooutput
usingMessageSet
wire format.void
writeDelimitedTo(java.io.OutputStream output)
void
writeTo(com.google.protobuf.CodedOutputStream output)
Serializes the set and writes it tooutput
.void
writeTo(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.Builder
and initialize it to be a copy ofcopyFrom
.
-
getDefaultInstance
public static UnknownFieldSet getDefaultInstance()
Get an emptyUnknownFieldSet
.
-
getDefaultInstanceForType
public UnknownFieldSet getDefaultInstanceForType()
- Specified by:
getDefaultInstanceForType
in interfacecom.google.protobuf.MessageLiteOrBuilder
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
isEmpty
public boolean isEmpty()
Whether the field set has no fields.
-
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(com.google.protobuf.CodedOutputStream output) throws java.io.IOException
Serializes the set and writes it tooutput
.- Specified by:
writeTo
in interfacecom.google.protobuf.MessageLite
- 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:
toString
in classjava.lang.Object
-
toByteString
public com.google.protobuf.ByteString toByteString()
Serializes the message to aByteString
and returns it. This is just a trivial wrapper aroundwriteTo(CodedOutputStream)
.- Specified by:
toByteString
in interfacecom.google.protobuf.MessageLite
-
toByteArray
public byte[] toByteArray()
Serializes the message to abyte
array and returns it. This is just a trivial wrapper aroundwriteTo(CodedOutputStream)
.- Specified by:
toByteArray
in interfacecom.google.protobuf.MessageLite
-
writeTo
public void writeTo(java.io.OutputStream output) throws java.io.IOException
Serializes the message and writes it tooutput
. This is just a trivial wrapper aroundwriteTo(CodedOutputStream)
.- Specified by:
writeTo
in interfacecom.google.protobuf.MessageLite
- Throws:
java.io.IOException
-
writeDelimitedTo
public void writeDelimitedTo(java.io.OutputStream output) throws java.io.IOException
- Specified by:
writeDelimitedTo
in interfacecom.google.protobuf.MessageLite
- Throws:
java.io.IOException
-
getSerializedSize
public int getSerializedSize()
Get the number of bytes required to encode this set.- Specified by:
getSerializedSize
in interfacecom.google.protobuf.MessageLite
-
writeAsMessageSetTo
public void writeAsMessageSetTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException
Serializes the set and writes it tooutput
usingMessageSet
wire format.- Throws:
java.io.IOException
-
getSerializedSizeAsMessageSet
public int getSerializedSizeAsMessageSet()
Get the number of bytes required to encode this set usingMessageSet
wire format.
-
isInitialized
public boolean isInitialized()
- Specified by:
isInitialized
in interfacecom.google.protobuf.MessageLiteOrBuilder
-
parseFrom
public static UnknownFieldSet parseFrom(com.google.protobuf.CodedInputStream input) throws java.io.IOException
Parse anUnknownFieldSet
from the given input stream.- Throws:
java.io.IOException
-
parseFrom
public static UnknownFieldSet parseFrom(com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException
Parsedata
as anUnknownFieldSet
and return it.- Throws:
com.google.protobuf.InvalidProtocolBufferException
-
parseFrom
public static UnknownFieldSet parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException
Parsedata
as anUnknownFieldSet
and return it.- Throws:
com.google.protobuf.InvalidProtocolBufferException
-
parseFrom
public static UnknownFieldSet parseFrom(java.io.InputStream input) throws java.io.IOException
Parse anUnknownFieldSet
frominput
and return it.- Throws:
java.io.IOException
-
newBuilderForType
public UnknownFieldSet.Builder newBuilderForType()
- Specified by:
newBuilderForType
in interfacecom.google.protobuf.MessageLite
-
toBuilder
public UnknownFieldSet.Builder toBuilder()
- Specified by:
toBuilder
in interfacecom.google.protobuf.MessageLite
-
getParserForType
public final UnknownFieldSet.Parser getParserForType()
- Specified by:
getParserForType
in interfacecom.google.protobuf.MessageLite
-
-