UnknownFieldSet
Date: 2017-07-08

com.google.protobuf

## Class UnknownFieldSet

- java.lang.Object
- - com.google.protobuf.UnknownFieldSet

- All Implemented Interfaces:
    MessageLite, MessageLiteOrBuilder

      public final class UnknownFieldSet
      extends java.lang.Object
      implements 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.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `UnknownFieldSet.Builder` Builder for `UnknownFieldSet`s.
    `static class` | `UnknownFieldSet.Field` Represents a single field in an `UnknownFieldSet`.
    `static class` | `UnknownFieldSet.Parser` Parser to implement MessageLite interface.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.util.Map<java.lang.Integer,UnknownFieldSet.Field>` | `asMap()` Get a map of fields in the set by number.
    `boolean` | `equals(java.lang.Object other)`
    `static UnknownFieldSet` | `getDefaultInstance()` Get an empty `UnknownFieldSet`.
    `UnknownFieldSet` | `getDefaultInstanceForType()` Get an instance of the type with no fields set.
    `UnknownFieldSet.Field` | `getField(int number)` Get a field by number.
    `UnknownFieldSet.Parser` | `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.Builder` | `newBuilder()` Create a new `UnknownFieldSet.Builder`.
    `static UnknownFieldSet.Builder` | `newBuilder(UnknownFieldSet copyFrom)` Create a new `UnknownFieldSet.Builder` and initialize it to be a copy of `copyFrom`.
    `UnknownFieldSet.Builder` | `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 data)` Parse `data` as an `UnknownFieldSet` and return it.
    `static UnknownFieldSet` | `parseFrom(CodedInputStream input)` Parse an `UnknownFieldSet` from the given input stream.
    `static UnknownFieldSet` | `parseFrom(java.io.InputStream input)` Parse an `UnknownFieldSet` from `input` and return it.
    `UnknownFieldSet.Builder` | `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.
    `java.lang.String` | `toString()` Converts the set to a string in protocol buffer text format.
    `void` | `writeAsMessageSetTo(CodedOutputStream output)` Serializes the set and writes it to `output` using `MessageSet` wire format.
    `void` | `writeDelimitedTo(java.io.OutputStream output)` Like `MessageLite.writeTo(OutputStream)`, but writes the size of the message as a varint before writing the data.
    `void` | `writeTo(CodedOutputStream output)` Serializes the set and writes it to `output`.
    `void` | `writeTo(java.io.OutputStream output)` Serializes the message and writes it to `output`.

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Method Detail

    - #### newBuilder

          public static UnknownFieldSet.Builder newBuilder()

      Create a new `UnknownFieldSet.Builder`.

    - #### newBuilder

          public static UnknownFieldSet.Builder newBuilder(UnknownFieldSet copyFrom)

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

    - #### getDefaultInstance

          public static UnknownFieldSet getDefaultInstance()

      Get an empty `UnknownFieldSet`.

    - #### getDefaultInstanceForType

          public UnknownFieldSet getDefaultInstanceForType()

      Description copied from interface: `MessageLiteOrBuilder`
      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.
      Specified by:
        `getDefaultInstanceForType` in interface `MessageLiteOrBuilder`

    - #### equals

          public boolean equals(java.lang.Object other)

      Overrides:
        `equals` in class `java.lang.Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `java.lang.Object`

    - #### asMap

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

      Get a map of fields in the set by number.

    - #### hasField

          public boolean hasField(int number)

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

    - #### getField

          public UnknownFieldSet.Field getField(int number)

      Get a field by number. Returns an empty field if not present. Never returns `null`.

    - #### writeTo

          public void writeTo(CodedOutputStream output)
                       throws java.io.IOException

      Serializes the set and writes it to `output`.
      Specified by:
        `writeTo` in interface `MessageLite`
      Throws:
        `java.io.IOException`

    - #### toString

          public java.lang.String toString()

      Converts the set to a string in protocol buffer text format. This is just a trivial wrapper around `TextFormat.printToString(UnknownFieldSet)`.
      Overrides:
        `toString` in class `java.lang.Object`

    - #### toByteString

          public ByteString toByteString()

      Serializes the message to a `ByteString` and returns it. This is just a trivial wrapper around `writeTo(CodedOutputStream)`.
      Specified by:
        `toByteString` in interface `MessageLite`

    - #### toByteArray

          public byte[] toByteArray()

      Serializes the message to a `byte` array and returns it. This is just a trivial wrapper around `writeTo(CodedOutputStream)`.
      Specified by:
        `toByteArray` in interface `MessageLite`

    - #### writeTo

          public void writeTo(java.io.OutputStream output)
                       throws java.io.IOException

      Serializes the message and writes it to `output`. This is just a trivial wrapper around `writeTo(CodedOutputStream)`.
      Specified by:
        `writeTo` in interface `MessageLite`
      Throws:
        `java.io.IOException`

    - #### writeDelimitedTo

          public void writeDelimitedTo(java.io.OutputStream output)
                                throws java.io.IOException

      Description copied from interface: `MessageLite`
      Like `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.
      Specified by:
        `writeDelimitedTo` in interface `MessageLite`
      Throws:
        `java.io.IOException`

    - #### getSerializedSize

          public int getSerializedSize()

      Get the number of bytes required to encode this set.
      Specified by:
        `getSerializedSize` in interface `MessageLite`

    - #### writeAsMessageSetTo

          public void writeAsMessageSetTo(CodedOutputStream output)
                                   throws java.io.IOException

      Serializes the set and writes it to `output` using `MessageSet` wire format.
      Throws:
        `java.io.IOException`

    - #### getSerializedSizeAsMessageSet

          public int getSerializedSizeAsMessageSet()

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

    - #### isInitialized

          public boolean isInitialized()

      Description copied from interface: `MessageLiteOrBuilder`
      Returns true if all required fields in the message and all embedded messages are set, false otherwise.

      See also: `MessageOrBuilder.getInitializationErrorString()`

      Specified by:
        `isInitialized` in interface `MessageLiteOrBuilder`

    - #### parseFrom

          public static UnknownFieldSet parseFrom(CodedInputStream input)
                                           throws java.io.IOException

      Parse an `UnknownFieldSet` from the given input stream.
      Throws:
        `java.io.IOException`

    - #### parseFrom

          public static UnknownFieldSet parseFrom(ByteString data)
                                           throws InvalidProtocolBufferException

      Parse `data` as an `UnknownFieldSet` and return it.
      Throws:
        `InvalidProtocolBufferException`

    - #### parseFrom

          public static UnknownFieldSet parseFrom(byte[] data)
                                           throws InvalidProtocolBufferException

      Parse `data` as an `UnknownFieldSet` and return it.
      Throws:
        `InvalidProtocolBufferException`

    - #### parseFrom

          public static UnknownFieldSet parseFrom(java.io.InputStream input)
                                           throws java.io.IOException

      Parse an `UnknownFieldSet` from `input` and return it.
      Throws:
        `java.io.IOException`

    - #### newBuilderForType

          public UnknownFieldSet.Builder newBuilderForType()

      Description copied from interface: `MessageLite`
      Constructs a new builder for a message of the same type as this message.
      Specified by:
        `newBuilderForType` in interface `MessageLite`

    - #### toBuilder

          public UnknownFieldSet.Builder toBuilder()

      Description copied from interface: `MessageLite`
      Constructs a builder initialized with the current message. Use this to derive a new message from the current one.
      Specified by:
        `toBuilder` in interface `MessageLite`

    - #### getParserForType

          public final UnknownFieldSet.Parser getParserForType()

      Description copied from interface: `MessageLite`
      Gets the parser for a message of the same type as this message.
      Specified by:
        `getParserForType` in interface `MessageLite`