public final class UnknownFieldSet extends Objectimplements MessageLite
UnknownFieldSet is used to keep 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 an UnknownFieldSet.Builder).
Most users will never need to use this class.
| Modifier and Type | Class and Description |
|---|---|
static class |
UnknownFieldSet
Builder for
UnknownFieldSets.
|
static class |
UnknownFieldSet
Represents a single field in an
UnknownFieldSet.
|
static class |
UnknownFieldSet
Parser to implement MessageLite interface.
|
| Modifier and Type | Method and Description |
|---|---|
Map |
asMap()
Get a map of fields in the set by number.
|
boolean |
equals(Object
|
static UnknownFieldSet |
getDefaultInstance()
Get an empty
UnknownFieldSet.
|
UnknownFieldSet |
getDefaultInstanceForType()
Get an instance of the type with no fields set.
|
UnknownFieldSet |
getField(int number)
Get a field by number.
|
UnknownFieldSet |
getParserForType()
Gets the parser for a message of the same type as this message.
|
int |
getSerializedSize()
Get the number of bytes required to encode this set.
|
int |
getSerializedSizeAsMessageSet()
Get the number of bytes required to encode this set using
MessageSet wire format.
|
boolean |
hasField(int number)
Check if the given field number is present in the set.
|
int |
hashCode()
|
boolean |
isInitialized()
Returns true if all required fields in the message and all embedded messages are set, false otherwise.
|
static UnknownFieldSet |
newBuilder()
Create a new
UnknownFieldSet.Builder.
|
static UnknownFieldSet |
newBuilder(UnknownFieldSet
Create a new
UnknownFieldSet.Builder and initialize it to be a copy of
copyFrom.
|
UnknownFieldSet |
newBuilderForType()
Constructs a new builder for a message of the same type as this message.
|
static UnknownFieldSet |
parseFrom(byte[] data)
Parse
data as an
UnknownFieldSet and return it.
|
static UnknownFieldSet |
parseFrom(ByteString
Parse
data as an
UnknownFieldSet and return it.
|
static UnknownFieldSet |
parseFrom(CodedInputStream
Parse an
UnknownFieldSet from the given input stream.
|
static UnknownFieldSet |
parseFrom(InputStream
Parse an
UnknownFieldSet from
input and return it.
|
UnknownFieldSet |
toBuilder()
Constructs a builder initialized with the current message.
|
byte[] |
toByteArray()
Serializes the message to a
byte array and returns it.
|
ByteString |
toByteString()
Serializes the message to a
ByteString and returns it.
|
String |
toString()
Converts the set to a string in protocol buffer text format.
|
void |
writeAsMessageSetTo(CodedOutputStream
Serializes the set and writes it to
output using
MessageSet wire format.
|
void |
writeDelimitedTo(OutputStream
Like
MessageLite, but writes the size of the message as a varint before writing the data.
|
void |
writeTo(CodedOutputStream
Serializes the set and writes it to
output.
|
void |
writeTo(OutputStream
Serializes the message and writes it to
output.
|
public static UnknownFieldSet.Builder newBuilder()
UnknownFieldSet.Builder.
public static UnknownFieldSet.Builder newBuilder(UnknownFieldSet copyFrom)
UnknownFieldSet.Builder and initialize it to be a copy of
copyFrom.
public static UnknownFieldSetgetDefaultInstance()
UnknownFieldSet.
public UnknownFieldSetgetDefaultInstanceForType()
MessageLiteOrBuilder
getDefaultInstance() method of generated message classes in that this method is an abstract method of the
MessageLite interface whereas
getDefaultInstance() is a static method of a specific class. They return the same thing.
public boolean equals(Objectother)
public int hashCode()
public Map<Integer ,UnknownFieldSet .Field > asMap()
public boolean hasField(int number)
public UnknownFieldSet.Field getField(int number)
null.
public void writeTo(CodedOutputStreamoutput) throws IOException
output.
writeTo in interface
MessageLite
IOException
public StringtoString()
TextFormat.printToString(UnknownFieldSet) .
public ByteStringtoByteString()
ByteString and returns it. This is just a trivial wrapper around
writeTo(CodedOutputStream).
public byte[] toByteArray()
byte array and returns it. This is just a trivial wrapper around
writeTo(CodedOutputStream).
public void writeTo(OutputStreamoutput) throws IOException
output. This is just a trivial wrapper around
writeTo(CodedOutputStream).
writeTo in interface
MessageLite
IOException
public void writeDelimitedTo(OutputStreamoutput) throws IOException
MessageLite
MessageLite.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. Use
MessageLite.Builder.mergeDelimitedFrom(InputStream) (or the static method
YourMessageType.parseDelimitedFrom(InputStream)) to parse messages written by this method.
writeDelimitedTo in interface
MessageLite
IOException
public int getSerializedSize()
public void writeAsMessageSetTo(CodedOutputStreamoutput) throws IOException
output using
MessageSet wire format.
IOException
public int getSerializedSizeAsMessageSet()
MessageSet wire format.
public boolean isInitialized()
MessageLiteOrBuilder
public static UnknownFieldSetparseFrom(CodedInputStream input) throws IOException
UnknownFieldSet from the given input stream.
IOException
public static UnknownFieldSetparseFrom(ByteString data) throws InvalidProtocolBufferException
data as an
UnknownFieldSet and return it.
InvalidProtocolBufferException
public static UnknownFieldSetparseFrom(byte[] data) throws InvalidProtocolBufferException
data as an
UnknownFieldSet and return it.
InvalidProtocolBufferException
public static UnknownFieldSetparseFrom(InputStream input) throws IOException
UnknownFieldSet from
input and return it.
IOException
public UnknownFieldSet.Builder newBuilderForType()
MessageLite
public UnknownFieldSet.Builder toBuilder()
MessageLite
public final UnknownFieldSet.Parser getParserForType()
MessageLite