Class CodedOutputStream.ArrayEncoder

    • Field Detail

      • buffer

        private final byte[] buffer
      • offset

        private final int offset
      • limit

        private final int limit
      • position

        private int position
    • Constructor Detail

      • ArrayEncoder

        ArrayEncoder​(byte[] buffer,
                     int offset,
                     int length)
    • Method Detail

      • writeTag

        public final void writeTag​(int fieldNumber,
                                   int wireType)
                            throws java.io.IOException
        Description copied from class: CodedOutputStream
        Encode and write a tag.
        Specified by:
        writeTag in class CodedOutputStream
        Throws:
        java.io.IOException
      • writeInt32

        public final void writeInt32​(int fieldNumber,
                                     int value)
                              throws java.io.IOException
        Description copied from class: CodedOutputStream
        Write an int32 field, including tag, to the stream.
        Specified by:
        writeInt32 in class CodedOutputStream
        Throws:
        java.io.IOException
      • writeUInt32

        public final void writeUInt32​(int fieldNumber,
                                      int value)
                               throws java.io.IOException
        Description copied from class: CodedOutputStream
        Write a uint32 field, including tag, to the stream.
        Specified by:
        writeUInt32 in class CodedOutputStream
        Throws:
        java.io.IOException
      • writeFixed32

        public final void writeFixed32​(int fieldNumber,
                                       int value)
                                throws java.io.IOException
        Description copied from class: CodedOutputStream
        Write a fixed32 field, including tag, to the stream.
        Specified by:
        writeFixed32 in class CodedOutputStream
        Throws:
        java.io.IOException
      • writeUInt64

        public final void writeUInt64​(int fieldNumber,
                                      long value)
                               throws java.io.IOException
        Description copied from class: CodedOutputStream
        Write a uint64 field, including tag, to the stream.
        Specified by:
        writeUInt64 in class CodedOutputStream
        Throws:
        java.io.IOException
      • writeFixed64

        public final void writeFixed64​(int fieldNumber,
                                       long value)
                                throws java.io.IOException
        Description copied from class: CodedOutputStream
        Write a fixed64 field, including tag, to the stream.
        Specified by:
        writeFixed64 in class CodedOutputStream
        Throws:
        java.io.IOException
      • writeBool

        public final void writeBool​(int fieldNumber,
                                    boolean value)
                             throws java.io.IOException
        Description copied from class: CodedOutputStream
        Write a bool field, including tag, to the stream.
        Specified by:
        writeBool in class CodedOutputStream
        Throws:
        java.io.IOException
      • writeString

        public final void writeString​(int fieldNumber,
                                      java.lang.String value)
                               throws java.io.IOException
        Description copied from class: CodedOutputStream
        Write a string field, including tag, to the stream.
        Specified by:
        writeString in class CodedOutputStream
        Throws:
        java.io.IOException
      • writeBytes

        public final void writeBytes​(int fieldNumber,
                                     ByteString value)
                              throws java.io.IOException
        Description copied from class: CodedOutputStream
        Write a bytes field, including tag, to the stream.
        Specified by:
        writeBytes in class CodedOutputStream
        Throws:
        java.io.IOException
      • writeByteArray

        public final void writeByteArray​(int fieldNumber,
                                         byte[] value)
                                  throws java.io.IOException
        Description copied from class: CodedOutputStream
        Write a bytes field, including tag, to the stream.
        Specified by:
        writeByteArray in class CodedOutputStream
        Throws:
        java.io.IOException
      • writeByteArray

        public final void writeByteArray​(int fieldNumber,
                                         byte[] value,
                                         int offset,
                                         int length)
                                  throws java.io.IOException
        Description copied from class: CodedOutputStream
        Write a bytes field, including tag, to the stream.
        Specified by:
        writeByteArray in class CodedOutputStream
        Throws:
        java.io.IOException
      • writeByteBuffer

        public final void writeByteBuffer​(int fieldNumber,
                                          java.nio.ByteBuffer value)
                                   throws java.io.IOException
        Description copied from class: CodedOutputStream
        Write a bytes field, including tag, to the stream. This method will write all content of the ByteBuffer regardless of the current position and limit (i.e., the number of bytes to be written is value.capacity(), not value.remaining()). Furthermore, this method doesn't alter the state of the passed-in ByteBuffer. Its position, limit, mark, etc. will remain unchanged. If you only want to write the remaining bytes of a ByteBuffer, you can call writeByteBuffer(fieldNumber, byteBuffer.slice()).
        Specified by:
        writeByteBuffer in class CodedOutputStream
        Throws:
        java.io.IOException
      • writeByteArrayNoTag

        public final void writeByteArrayNoTag​(byte[] value,
                                              int offset,
                                              int length)
                                       throws java.io.IOException
        Description copied from class: CodedOutputStream
        Write a bytes field to the stream. Visible for testing.
        Specified by:
        writeByteArrayNoTag in class CodedOutputStream
        Throws:
        java.io.IOException
      • writeRawBytes

        public final void writeRawBytes​(java.nio.ByteBuffer value)
                                 throws java.io.IOException
        Description copied from class: CodedOutputStream
        Write a ByteBuffer. This method will write all content of the ByteBuffer regardless of the current position and limit (i.e., the number of bytes to be written is value.capacity(), not value.remaining()). Furthermore, this method doesn't alter the state of the passed-in ByteBuffer. Its position, limit, mark, etc. will remain unchanged. If you only want to write the remaining bytes of a ByteBuffer, you can call writeRawBytes(byteBuffer.slice()).
        Specified by:
        writeRawBytes in class CodedOutputStream
        Throws:
        java.io.IOException
      • writeMessage

        public final void writeMessage​(int fieldNumber,
                                       MessageLite value)
                                throws java.io.IOException
        Description copied from class: CodedOutputStream
        Write an embedded message field, including tag, to the stream.
        Specified by:
        writeMessage in class CodedOutputStream
        Throws:
        java.io.IOException
      • writeMessage

        final void writeMessage​(int fieldNumber,
                                MessageLite value,
                                Schema schema)
                         throws java.io.IOException
        Description copied from class: CodedOutputStream
        Write an embedded message field, including tag, to the stream.
        Specified by:
        writeMessage in class CodedOutputStream
        Throws:
        java.io.IOException
      • writeMessageSetExtension

        public final void writeMessageSetExtension​(int fieldNumber,
                                                   MessageLite value)
                                            throws java.io.IOException
        Description copied from class: CodedOutputStream
        Write a MessageSet extension field to the stream. For historical reasons, the wire format differs from normal fields.
        Specified by:
        writeMessageSetExtension in class CodedOutputStream
        Throws:
        java.io.IOException
      • writeRawMessageSetExtension

        public final void writeRawMessageSetExtension​(int fieldNumber,
                                                      ByteString value)
                                               throws java.io.IOException
        Description copied from class: CodedOutputStream
        Write an unparsed MessageSet extension field to the stream. For historical reasons, the wire format differs from normal fields.
        Specified by:
        writeRawMessageSetExtension in class CodedOutputStream
        Throws:
        java.io.IOException
      • write

        public final void write​(byte value)
                         throws java.io.IOException
        Description copied from class: ByteOutput
        Writes a single byte.
        Specified by:
        write in class CodedOutputStream
        Parameters:
        value - the byte to be written
        Throws:
        java.io.IOException - thrown if an error occurred while writing
      • writeInt32NoTag

        public final void writeInt32NoTag​(int value)
                                   throws java.io.IOException
        Description copied from class: CodedOutputStream
        Write an int32 field to the stream.
        Specified by:
        writeInt32NoTag in class CodedOutputStream
        Throws:
        java.io.IOException
      • writeUInt32NoTag

        public final void writeUInt32NoTag​(int value)
                                    throws java.io.IOException
        Description copied from class: CodedOutputStream
        Write a uint32 field to the stream.
        Specified by:
        writeUInt32NoTag in class CodedOutputStream
        Throws:
        java.io.IOException
      • writeFixed32NoTag

        public final void writeFixed32NoTag​(int value)
                                     throws java.io.IOException
        Description copied from class: CodedOutputStream
        Write a fixed32 field to the stream.
        Specified by:
        writeFixed32NoTag in class CodedOutputStream
        Throws:
        java.io.IOException
      • writeUInt64NoTag

        public final void writeUInt64NoTag​(long value)
                                    throws java.io.IOException
        Description copied from class: CodedOutputStream
        Write a uint64 field to the stream.
        Specified by:
        writeUInt64NoTag in class CodedOutputStream
        Throws:
        java.io.IOException
      • writeFixed64NoTag

        public final void writeFixed64NoTag​(long value)
                                     throws java.io.IOException
        Description copied from class: CodedOutputStream
        Write a fixed64 field to the stream.
        Specified by:
        writeFixed64NoTag in class CodedOutputStream
        Throws:
        java.io.IOException
      • write

        public final void write​(byte[] value,
                                int offset,
                                int length)
                         throws java.io.IOException
        Description copied from class: ByteOutput
        Writes a sequence of bytes. The ByteOutput must copy value if it will not be processed prior to the return of this method call, since value may be reused/altered by the caller.

        NOTE: This method MUST NOT modify the value. Doing so is a programming error and will lead to data corruption which will be difficult to debug.

        Specified by:
        write in class CodedOutputStream
        Parameters:
        value - the bytes to be written
        offset - the offset of the start of the writable range
        length - the number of bytes to write starting from offset
        Throws:
        java.io.IOException - thrown if an error occurred while writing
      • writeLazy

        public final void writeLazy​(byte[] value,
                                    int offset,
                                    int length)
                             throws java.io.IOException
        Description copied from class: ByteOutput
        Writes a sequence of bytes. The ByteOutput is free to retain a reference to the value beyond the scope of this method call (e.g. write later) since it is considered immutable and is guaranteed not to change by the caller.

        NOTE: This method MUST NOT modify the value. Doing so is a programming error and will lead to data corruption which will be difficult to debug.

        Specified by:
        writeLazy in class CodedOutputStream
        Parameters:
        value - the bytes to be written
        offset - the offset of the start of the writable range
        length - the number of bytes to write starting from offset
        Throws:
        java.io.IOException - thrown if an error occurred while writing
      • write

        public final void write​(java.nio.ByteBuffer value)
                         throws java.io.IOException
        Description copied from class: ByteOutput
        Writes a sequence of bytes. The ByteOutput must copy value if it will not be processed prior to the return of this method call, since value may be reused/altered by the caller.

        NOTE: This method MUST NOT modify the value. Doing so is a programming error and will lead to data corruption which will be difficult to debug.

        Specified by:
        write in class CodedOutputStream
        Parameters:
        value - the bytes to be written. Upon returning from this call, the position of this buffer will be set to the limit
        Throws:
        java.io.IOException - thrown if an error occurred while writing
      • writeLazy

        public final void writeLazy​(java.nio.ByteBuffer value)
                             throws java.io.IOException
        Description copied from class: ByteOutput
        Writes a sequence of bytes. The ByteOutput is free to retain a reference to the value beyond the scope of this method call (e.g. write later) since it is considered immutable and is guaranteed not to change by the caller.

        NOTE: This method MUST NOT modify the value. Doing so is a programming error and will lead to data corruption which will be difficult to debug.

        Specified by:
        writeLazy in class CodedOutputStream
        Parameters:
        value - the bytes to be written. Upon returning from this call, the position of this buffer will be set to the limit
        Throws:
        java.io.IOException - thrown if an error occurred while writing
      • writeStringNoTag

        public final void writeStringNoTag​(java.lang.String value)
                                    throws java.io.IOException
        Description copied from class: CodedOutputStream
        Write a string field to the stream.
        Specified by:
        writeStringNoTag in class CodedOutputStream
        Throws:
        java.io.IOException
      • flush

        public void flush()
        Description copied from class: CodedOutputStream
        Flushes the stream and forces any buffered bytes to be written. This does not flush the underlying OutputStream.
        Specified by:
        flush in class CodedOutputStream
      • spaceLeft

        public final int spaceLeft()
        Description copied from class: CodedOutputStream
        If writing to a flat array, return the space left in the array. Otherwise, throws UnsupportedOperationException.
        Specified by:
        spaceLeft in class CodedOutputStream
      • getTotalBytesWritten

        public final int getTotalBytesWritten()
        Description copied from class: CodedOutputStream
        Get the total number of bytes successfully written to this stream. The returned value is not guaranteed to be accurate if exceptions have been found in the middle of writing.
        Specified by:
        getTotalBytesWritten in class CodedOutputStream