Interface MessageLite

    • Method Detail

      • getSerializedSize

        int getSerializedSize()
        Get the number of bytes required to encode this message. The result is only computed on the first call and memoized after that.
      • getParserForType

        Parser<? extends MessageLite> getParserForType()
        Gets the parser for a message of the same type as this message.
      • toByteArray

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

        void writeTo(OutputStream output)
              throws IOException
        Serializes the message and writes it to output. This is just a trivial wrapper around writeTo(CodedOutputStream). This does not flush or close the stream.

        NOTE: Protocol Buffers are not self-delimiting. Therefore, if you write any more data to the stream after the message, you must somehow ensure that the parser on the receiving end does not interpret this as being part of the protocol message. This can be done e.g. by writing the size of the message before the data, then making sure to limit the input to that size on the receiving end (e.g. by wrapping the InputStream in one which limits the input). Alternatively, just use writeDelimitedTo(OutputStream).

        Throws:
        IOException
      • newBuilderForType

        MessageLite.Builder newBuilderForType()
        Constructs a new builder for a message of the same type as this message.
      • toBuilder

        MessageLite.Builder toBuilder()
        Constructs a builder initialized with the current message. Use this to derive a new message from the current one.