Package com.google.protobuf
Class CodedOutputStream.OutputStreamEncoder
java.lang.Object
com.google.protobuf.ByteOutput
com.google.protobuf.CodedOutputStream
com.google.protobuf.CodedOutputStream.AbstractBufferedEncoder
com.google.protobuf.CodedOutputStream.OutputStreamEncoder
- Enclosing class:
- CodedOutputStream
private static final class CodedOutputStream.OutputStreamEncoder
extends CodedOutputStream.AbstractBufferedEncoder
An
CodedOutputStream that decorates an OutputStream. It performs internal
buffering to optimize writes to the OutputStream.-
Nested Class Summary
Nested classes/interfaces inherited from class com.google.protobuf.CodedOutputStream
CodedOutputStream.OutOfSpaceException -
Field Summary
FieldsFields inherited from class com.google.protobuf.CodedOutputStream.AbstractBufferedEncoder
buffer, limit, position, totalBytesWrittenFields inherited from class com.google.protobuf.CodedOutputStream
DEFAULT_BUFFER_SIZE, LITTLE_ENDIAN_32_SIZE, wrapper -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voiddoFlush()voidflush()Flushes the stream and forces any buffered bytes to be written.private voidflushIfNotAvailable(int requiredSize) voidwrite(byte value) Writes a single byte.voidwrite(byte[] value, int offset, int length) Writes a sequence of bytes.voidwrite(ByteBuffer value) Writes a sequence of bytes.voidwriteBool(int fieldNumber, boolean value) Write aboolfield, including tag, to the stream.voidwriteByteArray(int fieldNumber, byte[] value) Write abytesfield, including tag, to the stream.voidwriteByteArray(int fieldNumber, byte[] value, int offset, int length) Write abytesfield, including tag, to the stream.voidwriteByteArrayNoTag(byte[] value, int offset, int length) Write abytesfield to the stream.voidwriteByteBuffer(int fieldNumber, ByteBuffer value) Write abytesfield, including tag, to the stream.voidwriteBytes(int fieldNumber, ByteString value) Write abytesfield, including tag, to the stream.voidwriteBytesNoTag(ByteString value) Write abytesfield to the stream.voidwriteFixed32(int fieldNumber, int value) Write afixed32field, including tag, to the stream.voidwriteFixed32NoTag(int value) Write afixed32field to the stream.voidwriteFixed64(int fieldNumber, long value) Write afixed64field, including tag, to the stream.voidwriteFixed64NoTag(long value) Write afixed64field to the stream.voidwriteInt32(int fieldNumber, int value) Write anint32field, including tag, to the stream.voidwriteInt32NoTag(int value) Write anint32field to the stream.voidwriteLazy(byte[] value, int offset, int length) Writes a sequence of bytes.voidwriteLazy(ByteBuffer value) Writes a sequence of bytes.voidwriteMessage(int fieldNumber, MessageLite value) Write an embedded message field, including tag, to the stream.(package private) voidwriteMessage(int fieldNumber, MessageLite value, Schema schema) Write an embedded message field, including tag, to the stream.voidwriteMessageNoTag(MessageLite value) Write an embedded message field to the stream.(package private) voidwriteMessageNoTag(MessageLite value, Schema schema) Write an embedded message field to the stream.voidwriteMessageSetExtension(int fieldNumber, MessageLite value) Write a MessageSet extension field to the stream.voidwriteRawBytes(ByteBuffer value) Write a ByteBuffer.voidwriteRawMessageSetExtension(int fieldNumber, ByteString value) Write an unparsed MessageSet extension field to the stream.voidwriteString(int fieldNumber, String value) Write astringfield, including tag, to the stream.voidwriteStringNoTag(String value) Write astringfield to the stream.voidwriteTag(int fieldNumber, int wireType) Encode and write a tag.voidwriteUInt32(int fieldNumber, int value) Write auint32field, including tag, to the stream.voidwriteUInt32NoTag(int value) Write auint32field to the stream.voidwriteUInt64(int fieldNumber, long value) Write auint64field, including tag, to the stream.voidwriteUInt64NoTag(long value) Write auint64field to the stream.Methods inherited from class com.google.protobuf.CodedOutputStream.AbstractBufferedEncoder
buffer, bufferFixed32NoTag, bufferFixed64NoTag, bufferInt32NoTag, bufferTag, bufferUInt32NoTag, bufferUInt64NoTag, getTotalBytesWritten, spaceLeftMethods inherited from class com.google.protobuf.CodedOutputStream
checkNoSpaceLeft, computeBoolSize, computeBoolSizeNoTag, computeByteArraySize, computeByteArraySizeNoTag, computeByteBufferSize, computeByteBufferSizeNoTag, computeBytesSize, computeBytesSizeNoTag, computeDoubleSize, computeDoubleSizeNoTag, computeEnumSize, computeEnumSizeNoTag, computeFixed32Size, computeFixed32SizeNoTag, computeFixed64Size, computeFixed64SizeNoTag, computeFloatSize, computeFloatSizeNoTag, computeGroupSize, computeGroupSize, computeGroupSizeNoTag, computeGroupSizeNoTag, computeInt32Size, computeInt32SizeNoTag, computeInt64Size, computeInt64SizeNoTag, computeLazyFieldMessageSetExtensionSize, computeLazyFieldSize, computeLazyFieldSizeNoTag, computeLengthDelimitedFieldSize, computeMessageSetExtensionSize, computeMessageSize, computeMessageSize, computeMessageSizeNoTag, computeMessageSizeNoTag, computePreferredBufferSize, computeRawMessageSetExtensionSize, computeRawVarint32Size, computeRawVarint64Size, computeSFixed32Size, computeSFixed32SizeNoTag, computeSFixed64Size, computeSFixed64SizeNoTag, computeSInt32Size, computeSInt32SizeNoTag, computeSInt64Size, computeSInt64SizeNoTag, computeStringSize, computeStringSizeNoTag, computeTagSize, computeUInt32Size, computeUInt32SizeNoTag, computeUInt64Size, computeUInt64SizeNoTag, encodeZigZag32, encodeZigZag64, inefficientWriteStringNoTag, isSerializationDeterministic, newInstance, newInstance, newInstance, newInstance, newInstance, newInstance, newInstance, newSafeInstance, newUnsafeInstance, useDeterministicSerialization, writeBoolNoTag, writeByteArrayNoTag, writeDouble, writeDoubleNoTag, writeEnum, writeEnumNoTag, writeFloat, writeFloatNoTag, writeGroup, writeGroup, writeGroupNoTag, writeGroupNoTag, writeInt64, writeInt64NoTag, writeRawByte, writeRawByte, writeRawBytes, writeRawBytes, writeRawBytes, writeRawLittleEndian32, writeRawLittleEndian64, writeRawVarint32, writeRawVarint64, writeSFixed32, writeSFixed32NoTag, writeSFixed64, writeSFixed64NoTag, writeSInt32, writeSInt32NoTag, writeSInt64, writeSInt64NoTag
-
Field Details
-
out
-
-
Constructor Details
-
OutputStreamEncoder
OutputStreamEncoder(OutputStream out, int bufferSize)
-
-
Method Details
-
writeTag
Description copied from class:CodedOutputStreamEncode and write a tag.- Specified by:
writeTagin classCodedOutputStream- Throws:
IOException
-
writeInt32
Description copied from class:CodedOutputStreamWrite anint32field, including tag, to the stream.- Specified by:
writeInt32in classCodedOutputStream- Throws:
IOException
-
writeUInt32
Description copied from class:CodedOutputStreamWrite auint32field, including tag, to the stream.- Specified by:
writeUInt32in classCodedOutputStream- Throws:
IOException
-
writeFixed32
Description copied from class:CodedOutputStreamWrite afixed32field, including tag, to the stream.- Specified by:
writeFixed32in classCodedOutputStream- Throws:
IOException
-
writeUInt64
Description copied from class:CodedOutputStreamWrite auint64field, including tag, to the stream.- Specified by:
writeUInt64in classCodedOutputStream- Throws:
IOException
-
writeFixed64
Description copied from class:CodedOutputStreamWrite afixed64field, including tag, to the stream.- Specified by:
writeFixed64in classCodedOutputStream- Throws:
IOException
-
writeBool
Description copied from class:CodedOutputStreamWrite aboolfield, including tag, to the stream.- Specified by:
writeBoolin classCodedOutputStream- Throws:
IOException
-
writeString
Description copied from class:CodedOutputStreamWrite astringfield, including tag, to the stream.- Specified by:
writeStringin classCodedOutputStream- Throws:
IOException
-
writeBytes
Description copied from class:CodedOutputStreamWrite abytesfield, including tag, to the stream.- Specified by:
writeBytesin classCodedOutputStream- Throws:
IOException
-
writeByteArray
Description copied from class:CodedOutputStreamWrite abytesfield, including tag, to the stream.- Specified by:
writeByteArrayin classCodedOutputStream- Throws:
IOException
-
writeByteArray
public void writeByteArray(int fieldNumber, byte[] value, int offset, int length) throws IOException Description copied from class:CodedOutputStreamWrite abytesfield, including tag, to the stream.- Specified by:
writeByteArrayin classCodedOutputStream- Throws:
IOException
-
writeByteBuffer
Description copied from class:CodedOutputStreamWrite abytesfield, 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 callwriteByteBuffer(fieldNumber, byteBuffer.slice()).- Specified by:
writeByteBufferin classCodedOutputStream- Throws:
IOException
-
writeBytesNoTag
Description copied from class:CodedOutputStreamWrite abytesfield to the stream.- Specified by:
writeBytesNoTagin classCodedOutputStream- Throws:
IOException
-
writeByteArrayNoTag
Description copied from class:CodedOutputStreamWrite abytesfield to the stream. Visible for testing.- Specified by:
writeByteArrayNoTagin classCodedOutputStream- Throws:
IOException
-
writeRawBytes
Description copied from class:CodedOutputStreamWrite 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 callwriteRawBytes(byteBuffer.slice()).- Specified by:
writeRawBytesin classCodedOutputStream- Throws:
IOException
-
writeMessage
Description copied from class:CodedOutputStreamWrite an embedded message field, including tag, to the stream.- Specified by:
writeMessagein classCodedOutputStream- Throws:
IOException
-
writeMessage
Description copied from class:CodedOutputStreamWrite an embedded message field, including tag, to the stream.- Specified by:
writeMessagein classCodedOutputStream- Throws:
IOException
-
writeMessageSetExtension
Description copied from class:CodedOutputStreamWrite a MessageSet extension field to the stream. For historical reasons, the wire format differs from normal fields.- Specified by:
writeMessageSetExtensionin classCodedOutputStream- Throws:
IOException
-
writeRawMessageSetExtension
Description copied from class:CodedOutputStreamWrite an unparsed MessageSet extension field to the stream. For historical reasons, the wire format differs from normal fields.- Specified by:
writeRawMessageSetExtensionin classCodedOutputStream- Throws:
IOException
-
writeMessageNoTag
Description copied from class:CodedOutputStreamWrite an embedded message field to the stream.- Specified by:
writeMessageNoTagin classCodedOutputStream- Throws:
IOException
-
writeMessageNoTag
Description copied from class:CodedOutputStreamWrite an embedded message field to the stream.- Specified by:
writeMessageNoTagin classCodedOutputStream- Throws:
IOException
-
write
Description copied from class:ByteOutputWrites a single byte.- Specified by:
writein classCodedOutputStream- Parameters:
value- the byte to be written- Throws:
IOException- thrown if an error occurred while writing
-
writeInt32NoTag
Description copied from class:CodedOutputStreamWrite anint32field to the stream.- Specified by:
writeInt32NoTagin classCodedOutputStream- Throws:
IOException
-
writeUInt32NoTag
Description copied from class:CodedOutputStreamWrite auint32field to the stream.- Specified by:
writeUInt32NoTagin classCodedOutputStream- Throws:
IOException
-
writeFixed32NoTag
Description copied from class:CodedOutputStreamWrite afixed32field to the stream.- Specified by:
writeFixed32NoTagin classCodedOutputStream- Throws:
IOException
-
writeUInt64NoTag
Description copied from class:CodedOutputStreamWrite auint64field to the stream.- Specified by:
writeUInt64NoTagin classCodedOutputStream- Throws:
IOException
-
writeFixed64NoTag
Description copied from class:CodedOutputStreamWrite afixed64field to the stream.- Specified by:
writeFixed64NoTagin classCodedOutputStream- Throws:
IOException
-
writeStringNoTag
Description copied from class:CodedOutputStreamWrite astringfield to the stream.- Specified by:
writeStringNoTagin classCodedOutputStream- Throws:
IOException
-
flush
Description copied from class:CodedOutputStreamFlushes the stream and forces any buffered bytes to be written. This does not flush the underlying OutputStream.- Specified by:
flushin classCodedOutputStream- Throws:
IOException
-
write
Description copied from class:ByteOutputWrites a sequence of bytes. TheByteOutputmust copyvalueif it will not be processed prior to the return of this method call, sincevaluemay 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:
writein classCodedOutputStream- Parameters:
value- the bytes to be writtenoffset- the offset of the start of the writable rangelength- the number of bytes to write starting fromoffset- Throws:
IOException- thrown if an error occurred while writing
-
writeLazy
Description copied from class:ByteOutputWrites a sequence of bytes. TheByteOutputis 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:
writeLazyin classCodedOutputStream- Parameters:
value- the bytes to be writtenoffset- the offset of the start of the writable rangelength- the number of bytes to write starting fromoffset- Throws:
IOException- thrown if an error occurred while writing
-
write
Description copied from class:ByteOutputWrites a sequence of bytes. TheByteOutputmust copyvalueif it will not be processed prior to the return of this method call, sincevaluemay 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:
writein classCodedOutputStream- Parameters:
value- the bytes to be written. Upon returning from this call, thepositionof this buffer will be set to thelimit- Throws:
IOException- thrown if an error occurred while writing
-
writeLazy
Description copied from class:ByteOutputWrites a sequence of bytes. TheByteOutputis 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:
writeLazyin classCodedOutputStream- Parameters:
value- the bytes to be written. Upon returning from this call, thepositionof this buffer will be set to thelimit- Throws:
IOException- thrown if an error occurred while writing
-
flushIfNotAvailable
- Throws:
IOException
-
doFlush
- Throws:
IOException
-