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.
Implements
MessageLiteStatic Methods
getDefaultInstance()
public
static
UnknownFieldSet
getDefaultInstance
()
Get an empty UnknownFieldSet
.
newBuilder()
public
static
UnknownFieldSet
.
Builder
newBuilder
()
Create a new Builder .
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.
parseFrom(ByteString data)
public
static
UnknownFieldSet
parseFrom
(
ByteString
data
)
Parse data
as an UnknownFieldSet
and return it.
parseFrom(CodedInputStream input)
public
static
UnknownFieldSet
parseFrom
(
CodedInputStream
input
)
Parse an UnknownFieldSet
from the given input stream.
parseFrom(InputStream input)
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
)
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
.
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.
getSerializedSizeAsMessageSet()
public
int
getSerializedSizeAsMessageSet
()
Get the number of bytes required to encode this set using MessageSet
wire format.
hasField(int number)
public
boolean
hasField
(
int
number
)
Check if the given field number is present in the set.
hashCode()
public
int
hashCode
()
isInitialized()
public
boolean
isInitialized
()
Returns true if all required fields in the message and all embedded messages are set, false otherwise.
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
()
Serializes the message to a byte
array and returns it. This is just a trivial wrapper
around #writeTo(CodedOutputStream)
.
toByteString()
public
ByteString
toByteString
()
Serializes the message to a ByteString
and returns it. This is just a trivial wrapper
around #writeTo(CodedOutputStream)
.
toString()
public
String
toString
()
Converts the set to a string in protocol buffer text format. This is just a trivial wrapper around TextFormat.Printer#printToString(UnknownFieldSet) .
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
)
Serializes the message and writes it to output
. This is just a trivial wrapper around #writeTo(CodedOutputStream)
.

