Class UnknownFieldSet (3.19.4)

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

Implements

MessageLite

Static Methods

getDefaultInstance()

public static UnknownFieldSet getDefaultInstance()

Get an empty UnknownFieldSet.

Returns
TypeDescription
UnknownFieldSet

newBuilder()

public static UnknownFieldSet.Builder newBuilder()

Create a new Builder.

Returns
TypeDescription
UnknownFieldSet.Builder

newBuilder(UnknownFieldSet copyFrom)

public static UnknownFieldSet.Builder newBuilder(UnknownFieldSet copyFrom)

Create a new Builder and initialize it to be a copy of copyFrom.

Parameter
NameDescription
copyFromUnknownFieldSet
Returns
TypeDescription
UnknownFieldSet.Builder

parseFrom(byte[] data)

public static UnknownFieldSet parseFrom(byte[] data)

Parse data as an UnknownFieldSet and return it.

Parameter
NameDescription
databyte[]
Returns
TypeDescription
UnknownFieldSet
Exceptions
TypeDescription
InvalidProtocolBufferException

parseFrom(ByteString data)

public static UnknownFieldSet parseFrom(ByteString data)

Parse data as an UnknownFieldSet and return it.

Parameter
NameDescription
dataByteString
Returns
TypeDescription
UnknownFieldSet
Exceptions
TypeDescription
InvalidProtocolBufferException

parseFrom(CodedInputStream input)

public static UnknownFieldSet parseFrom(CodedInputStream input)

Parse an UnknownFieldSet from the given input stream.

Parameter
NameDescription
inputCodedInputStream
Returns
TypeDescription
UnknownFieldSet
Exceptions
TypeDescription
IOException

parseFrom(InputStream input)

public static UnknownFieldSet parseFrom(InputStream input)

Parse an UnknownFieldSet from input and return it.

Parameter
NameDescription
inputInputStream
Returns
TypeDescription
UnknownFieldSet
Exceptions
TypeDescription
IOException

Methods

asMap()

public Map<Integer,UnknownFieldSet.Field> asMap()

Get a map of fields in the set by number.

Returns
TypeDescription
Map<Integer,Field>

equals(Object other)

public boolean equals(Object other)
Parameter
NameDescription
otherObject
Returns
TypeDescription
boolean
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
TypeDescription
UnknownFieldSet

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
NameDescription
numberint
Returns
TypeDescription
UnknownFieldSet.Field

getParserForType()

public final UnknownFieldSet.Parser getParserForType()

Gets the parser for a message of the same type as this message.

Returns
TypeDescription
UnknownFieldSet.Parser

getSerializedSize()

public int getSerializedSize()

Get the number of bytes required to encode this set.

Returns
TypeDescription
int

getSerializedSizeAsMessageSet()

public int getSerializedSizeAsMessageSet()

Get the number of bytes required to encode this set using MessageSet wire format.

Returns
TypeDescription
int

hasField(int number)

public boolean hasField(int number)

Check if the given field number is present in the set.

Parameter
NameDescription
numberint
Returns
TypeDescription
boolean

hashCode()

public int hashCode()
Returns
TypeDescription
int
Overrides

isInitialized()

public boolean isInitialized()

Returns true if all required fields in the message and all embedded messages are set, false otherwise.

See also: MessageOrBuilder#getInitializationErrorString()

Returns
TypeDescription
boolean

newBuilderForType()

public UnknownFieldSet.Builder newBuilderForType()

Constructs a new builder for a message of the same type as this message.

Returns
TypeDescription
UnknownFieldSet.Builder

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
TypeDescription
UnknownFieldSet.Builder

toByteArray()

public byte[] toByteArray()

Serializes the message to a byte array and returns it. This is just a trivial wrapper around #writeTo(CodedOutputStream).

Returns
TypeDescription
byte[]

toByteString()

public ByteString toByteString()

Serializes the message to a ByteString and returns it. This is just a trivial wrapper around #writeTo(CodedOutputStream).

Returns
TypeDescription
ByteString

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).

Returns
TypeDescription
String
Overrides

writeAsMessageSetTo(CodedOutputStream output)

public void writeAsMessageSetTo(CodedOutputStream output)

Serializes the set and writes it to output using MessageSet wire format.

Parameter
NameDescription
outputCodedOutputStream
Exceptions
TypeDescription
IOException

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
NameDescription
outputOutputStream
Exceptions
TypeDescription
IOException

writeTo(CodedOutputStream output)

public void writeTo(CodedOutputStream output)

Serializes the set and writes it to output.

Parameter
NameDescription
outputCodedOutputStream
Exceptions
TypeDescription
IOException

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).

Parameter
NameDescription
outputOutputStream
Exceptions
TypeDescription
IOException