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
.
newBuilder()
public static UnknownFieldSet.Builder newBuilder()
newBuilder(UnknownFieldSet copyFrom)
public static UnknownFieldSet.Builder newBuilder(UnknownFieldSet copyFrom)
Create a new Builder and initialize it to be a copy of copyFrom
.
parseFrom(byte[] data)
public static UnknownFieldSet parseFrom(byte[] data)
Parse data
as an UnknownFieldSet
and return it.
Parameter |
---|
Name | Description |
data | byte[]
|
parseFrom(ByteString data)
public static UnknownFieldSet parseFrom(ByteString data)
Parse data
as an UnknownFieldSet
and return it.
public static UnknownFieldSet parseFrom(CodedInputStream input)
Parse an UnknownFieldSet
from the given input stream.
public static UnknownFieldSet parseFrom(InputStream input)
Parse an UnknownFieldSet
from input
and return it.
Methods
asMap()
public Map<Integer,UnknownFieldSet.Field> asMap()
Get a map of fields in the set by number.
equals(Object other)
public boolean equals(Object other)
Parameter |
---|
Name | Description |
other | Object
|
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.
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 |
---|
Name | Description |
number | int
|
getParserForType()
public final UnknownFieldSet.Parser getParserForType()
Gets the parser for a message of the same type as this message.
getSerializedSize()
public int getSerializedSize()
Get the number of bytes required to encode this set.
Returns |
---|
Type | Description |
int | |
getSerializedSizeAsMessageSet()
public int getSerializedSizeAsMessageSet()
Get the number of bytes required to encode this set using MessageSet
wire format.
Returns |
---|
Type | Description |
int | |
hasField(int number)
public boolean hasField(int number)
Check if the given field number is present in the set.
Parameter |
---|
Name | Description |
number | int
|
hashCode()
Returns |
---|
Type | Description |
int | |
Overrides
isInitialized()
public boolean isInitialized()
newBuilderForType()
public UnknownFieldSet.Builder newBuilderForType()
Constructs a new builder for a message of the same type as this message.
toBuilder()
public UnknownFieldSet.Builder toBuilder()
Constructs a builder initialized with the current message. Use this to derive a new message
from the current one.
toByteArray()
public byte[] toByteArray()
Returns |
---|
Type | Description |
byte[] | |
toByteString()
public ByteString toByteString()
toString()
Overrides
writeAsMessageSetTo(CodedOutputStream output)
public void writeAsMessageSetTo(CodedOutputStream output)
Serializes the set and writes it to output
using MessageSet
wire format.
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.
writeTo(CodedOutputStream output)
public void writeTo(CodedOutputStream output)
Serializes the set and writes it to output
.
writeTo(OutputStream output)
public void writeTo(OutputStream output)