Class CodedOutputStream.OutputStreamEncoder

    • Field Detail

      • out

        private final java.io.OutputStream out
    • Constructor Detail

      • OutputStreamEncoder

        OutputStreamEncoder​(java.io.OutputStream out,
                            int bufferSize)
    • Method Detail

      • writeTag

        public 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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
      • writeMessageSetExtension

        public 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 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 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 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 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 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 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 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
      • writeStringNoTag

        public 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()
                   throws java.io.IOException
        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
        Throws:
        java.io.IOException
      • write

        public 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 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 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 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
      • flushIfNotAvailable

        private void flushIfNotAvailable​(int requiredSize)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • doFlush

        private void doFlush()
                      throws java.io.IOException
        Throws:
        java.io.IOException