public final class UnknownFieldSet implements 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 an UnknownFieldSet
(and every Message.Builder
contains a Builder).
Most users will never need to use this class.
Inheritance
Object >
UnknownFieldSet
Static Methods
getDefaultInstance()
public static UnknownFieldSet getDefaultInstance()
Get an empty UnknownFieldSet
.
Returns
newBuilder()
public static UnknownFieldSet.Builder newBuilder()
Returns
newBuilder(UnknownFieldSet copyFrom)
public static UnknownFieldSet.Builder newBuilder(UnknownFieldSet copyFrom)
Create a new Builder and initialize it to be a copy of copyFrom
.
Parameter
Returns
parseFrom(byte[] data)
public static UnknownFieldSet parseFrom(byte[] data)
Parse data
as an UnknownFieldSet
and return it.
Parameter
Name | Description |
data | byte[]
|
Returns
Exceptions
parseFrom(ByteString data)
public static UnknownFieldSet parseFrom(ByteString data)
Parse data
as an UnknownFieldSet
and return it.
Parameter
Returns
Exceptions
public static UnknownFieldSet parseFrom(CodedInputStream input)
Parse an UnknownFieldSet
from the given input stream.
Parameter
Returns
Exceptions
public static UnknownFieldSet parseFrom(InputStream input)
Parse an UnknownFieldSet
from input
and return it.
Parameter
Returns
Exceptions
Methods
asMap()
public Map<Integer,UnknownFieldSet.Field> asMap()
Get a map of fields in the set by number.
Returns
equals(Object other)
public boolean equals(Object other)
Parameter
Returns
Overrides
getDefaultInstanceForType()
public UnknownFieldSet getDefaultInstanceForType()
Get 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 the 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.
Returns
getField(int number)
public UnknownFieldSet.Field getField(int number)
Get a field by number. Returns an empty field if not present. Never returns null
.
Parameter
Returns
getParserForType()
public final UnknownFieldSet.Parser getParserForType()
Gets the parser for a message of the same type as this message.
Returns
getSerializedSize()
public int getSerializedSize()
Get the number of bytes required to encode this set.
Returns
getSerializedSizeAsMessageSet()
public int getSerializedSizeAsMessageSet()
Get the number of bytes required to encode this set using MessageSet
wire format.
Returns
hasField(int number)
public boolean hasField(int number)
Check if the given field number is present in the set.
Parameter
Returns
hashCode()
Returns
Overrides
isInitialized()
public boolean isInitialized()
Returns
newBuilderForType()
public UnknownFieldSet.Builder newBuilderForType()
Constructs a new builder for a message of the same type as this message.
Returns
toBuilder()
public UnknownFieldSet.Builder toBuilder()
Constructs a builder initialized with the current message. Use this to derive a new message
from the current one.
Returns
toByteArray()
public byte[] toByteArray()
Returns
toByteString()
public ByteString toByteString()
Returns
toString()
Returns
Overrides
writeAsMessageSetTo(CodedOutputStream output)
public void writeAsMessageSetTo(CodedOutputStream output)
Serializes the set and writes it to output
using MessageSet
wire format.
Parameter
Exceptions
writeDelimitedTo(OutputStream output)
public void writeDelimitedTo(OutputStream output)
Like #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 Builder#mergeDelimitedFrom(InputStream) (or the static method
YourMessageType.parseDelimitedFrom(InputStream)
) to parse messages written by this method.
Parameter
Exceptions
writeTo(CodedOutputStream output)
public void writeTo(CodedOutputStream output)
Serializes the set and writes it to output
.
Parameter
Exceptions
writeTo(OutputStream output)
public void writeTo(OutputStream output)
Parameter
Exceptions