Package com.google.protobuf
Class CodedOutputStream.ByteOutputEncoder
- java.lang.Object
-
- com.google.protobuf.ByteOutput
-
- com.google.protobuf.CodedOutputStream
-
- com.google.protobuf.CodedOutputStream.AbstractBufferedEncoder
-
- com.google.protobuf.CodedOutputStream.ByteOutputEncoder
-
- Enclosing class:
- CodedOutputStream
private static final class CodedOutputStream.ByteOutputEncoder extends CodedOutputStream.AbstractBufferedEncoder
ACodedOutputStream
that decorates aByteOutput
. It internal buffer only to support string encoding operations. All other writes are just passed through to theByteOutput
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.google.protobuf.CodedOutputStream
CodedOutputStream.OutOfSpaceException
-
-
Field Summary
Fields Modifier and Type Field Description private ByteOutput
out
-
Fields inherited from class com.google.protobuf.CodedOutputStream.AbstractBufferedEncoder
buffer, limit, position, totalBytesWritten
-
Fields inherited from class com.google.protobuf.CodedOutputStream
DEFAULT_BUFFER_SIZE, LITTLE_ENDIAN_32_SIZE, wrapper
-
-
Constructor Summary
Constructors Constructor Description ByteOutputEncoder(ByteOutput out, int bufferSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
doFlush()
void
flush()
Flushes the stream and forces any buffered bytes to be written.private void
flushIfNotAvailable(int requiredSize)
void
write(byte value)
Writes a single byte.void
write(byte[] value, int offset, int length)
Writes a sequence of bytes.void
write(java.nio.ByteBuffer value)
Writes a sequence of bytes.void
writeBool(int fieldNumber, boolean value)
Write abool
field, including tag, to the stream.void
writeByteArray(int fieldNumber, byte[] value)
Write abytes
field, including tag, to the stream.void
writeByteArray(int fieldNumber, byte[] value, int offset, int length)
Write abytes
field, including tag, to the stream.void
writeByteArrayNoTag(byte[] value, int offset, int length)
Write abytes
field to the stream.void
writeByteBuffer(int fieldNumber, java.nio.ByteBuffer value)
Write abytes
field, including tag, to the stream.void
writeBytes(int fieldNumber, ByteString value)
Write abytes
field, including tag, to the stream.void
writeBytesNoTag(ByteString value)
Write abytes
field to the stream.void
writeFixed32(int fieldNumber, int value)
Write afixed32
field, including tag, to the stream.void
writeFixed32NoTag(int value)
Write afixed32
field to the stream.void
writeFixed64(int fieldNumber, long value)
Write afixed64
field, including tag, to the stream.void
writeFixed64NoTag(long value)
Write afixed64
field to the stream.void
writeInt32(int fieldNumber, int value)
Write anint32
field, including tag, to the stream.void
writeInt32NoTag(int value)
Write anint32
field to the stream.void
writeLazy(byte[] value, int offset, int length)
Writes a sequence of bytes.void
writeLazy(java.nio.ByteBuffer value)
Writes a sequence of bytes.void
writeMessage(int fieldNumber, MessageLite value)
Write an embedded message field, including tag, to the stream.(package private) void
writeMessage(int fieldNumber, MessageLite value, Schema schema)
Write an embedded message field, including tag, to the stream.void
writeMessageNoTag(MessageLite value)
Write an embedded message field to the stream.(package private) void
writeMessageNoTag(MessageLite value, Schema schema)
Write an embedded message field to the stream.void
writeMessageSetExtension(int fieldNumber, MessageLite value)
Write a MessageSet extension field to the stream.void
writeRawBytes(java.nio.ByteBuffer value)
Write a ByteBuffer.void
writeRawMessageSetExtension(int fieldNumber, ByteString value)
Write an unparsed MessageSet extension field to the stream.void
writeString(int fieldNumber, java.lang.String value)
Write astring
field, including tag, to the stream.void
writeStringNoTag(java.lang.String value)
Write astring
field to the stream.void
writeTag(int fieldNumber, int wireType)
Encode and write a tag.void
writeUInt32(int fieldNumber, int value)
Write auint32
field, including tag, to the stream.void
writeUInt32NoTag(int value)
Write auint32
field to the stream.void
writeUInt64(int fieldNumber, long value)
Write auint64
field, including tag, to the stream.void
writeUInt64NoTag(long value)
Write auint64
field to the stream.-
Methods inherited from class com.google.protobuf.CodedOutputStream.AbstractBufferedEncoder
buffer, bufferFixed32NoTag, bufferFixed64NoTag, bufferInt32NoTag, bufferTag, bufferUInt32NoTag, bufferUInt64NoTag, getTotalBytesWritten, spaceLeft
-
Methods 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 Detail
-
out
private final ByteOutput out
-
-
Constructor Detail
-
ByteOutputEncoder
ByteOutputEncoder(ByteOutput 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 classCodedOutputStream
- Throws:
java.io.IOException
-
writeInt32
public void writeInt32(int fieldNumber, int value) throws java.io.IOException
Description copied from class:CodedOutputStream
Write anint32
field, including tag, to the stream.- Specified by:
writeInt32
in classCodedOutputStream
- Throws:
java.io.IOException
-
writeUInt32
public void writeUInt32(int fieldNumber, int value) throws java.io.IOException
Description copied from class:CodedOutputStream
Write auint32
field, including tag, to the stream.- Specified by:
writeUInt32
in classCodedOutputStream
- Throws:
java.io.IOException
-
writeFixed32
public void writeFixed32(int fieldNumber, int value) throws java.io.IOException
Description copied from class:CodedOutputStream
Write afixed32
field, including tag, to the stream.- Specified by:
writeFixed32
in classCodedOutputStream
- Throws:
java.io.IOException
-
writeUInt64
public void writeUInt64(int fieldNumber, long value) throws java.io.IOException
Description copied from class:CodedOutputStream
Write auint64
field, including tag, to the stream.- Specified by:
writeUInt64
in classCodedOutputStream
- Throws:
java.io.IOException
-
writeFixed64
public void writeFixed64(int fieldNumber, long value) throws java.io.IOException
Description copied from class:CodedOutputStream
Write afixed64
field, including tag, to the stream.- Specified by:
writeFixed64
in classCodedOutputStream
- Throws:
java.io.IOException
-
writeBool
public void writeBool(int fieldNumber, boolean value) throws java.io.IOException
Description copied from class:CodedOutputStream
Write abool
field, including tag, to the stream.- Specified by:
writeBool
in classCodedOutputStream
- Throws:
java.io.IOException
-
writeString
public void writeString(int fieldNumber, java.lang.String value) throws java.io.IOException
Description copied from class:CodedOutputStream
Write astring
field, including tag, to the stream.- Specified by:
writeString
in classCodedOutputStream
- Throws:
java.io.IOException
-
writeBytes
public void writeBytes(int fieldNumber, ByteString value) throws java.io.IOException
Description copied from class:CodedOutputStream
Write abytes
field, including tag, to the stream.- Specified by:
writeBytes
in classCodedOutputStream
- Throws:
java.io.IOException
-
writeByteArray
public void writeByteArray(int fieldNumber, byte[] value) throws java.io.IOException
Description copied from class:CodedOutputStream
Write abytes
field, including tag, to the stream.- Specified by:
writeByteArray
in classCodedOutputStream
- 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 abytes
field, including tag, to the stream.- Specified by:
writeByteArray
in classCodedOutputStream
- Throws:
java.io.IOException
-
writeByteBuffer
public void writeByteBuffer(int fieldNumber, java.nio.ByteBuffer value) throws java.io.IOException
Description copied from class:CodedOutputStream
Write abytes
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 callwriteByteBuffer(fieldNumber, byteBuffer.slice())
.- Specified by:
writeByteBuffer
in classCodedOutputStream
- Throws:
java.io.IOException
-
writeBytesNoTag
public void writeBytesNoTag(ByteString value) throws java.io.IOException
Description copied from class:CodedOutputStream
Write abytes
field to the stream.- Specified by:
writeBytesNoTag
in classCodedOutputStream
- Throws:
java.io.IOException
-
writeByteArrayNoTag
public void writeByteArrayNoTag(byte[] value, int offset, int length) throws java.io.IOException
Description copied from class:CodedOutputStream
Write abytes
field to the stream. Visible for testing.- Specified by:
writeByteArrayNoTag
in classCodedOutputStream
- 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 callwriteRawBytes(byteBuffer.slice())
.- Specified by:
writeRawBytes
in classCodedOutputStream
- 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 classCodedOutputStream
- Throws:
java.io.IOException
-
writeMessage
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 classCodedOutputStream
- 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 classCodedOutputStream
- 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 classCodedOutputStream
- Throws:
java.io.IOException
-
writeMessageNoTag
public void writeMessageNoTag(MessageLite value) throws java.io.IOException
Description copied from class:CodedOutputStream
Write an embedded message field to the stream.- Specified by:
writeMessageNoTag
in classCodedOutputStream
- Throws:
java.io.IOException
-
writeMessageNoTag
void writeMessageNoTag(MessageLite value, Schema schema) throws java.io.IOException
Description copied from class:CodedOutputStream
Write an embedded message field to the stream.- Specified by:
writeMessageNoTag
in classCodedOutputStream
- 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 classCodedOutputStream
- 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 anint32
field to the stream.- Specified by:
writeInt32NoTag
in classCodedOutputStream
- Throws:
java.io.IOException
-
writeUInt32NoTag
public void writeUInt32NoTag(int value) throws java.io.IOException
Description copied from class:CodedOutputStream
Write auint32
field to the stream.- Specified by:
writeUInt32NoTag
in classCodedOutputStream
- Throws:
java.io.IOException
-
writeFixed32NoTag
public void writeFixed32NoTag(int value) throws java.io.IOException
Description copied from class:CodedOutputStream
Write afixed32
field to the stream.- Specified by:
writeFixed32NoTag
in classCodedOutputStream
- Throws:
java.io.IOException
-
writeUInt64NoTag
public void writeUInt64NoTag(long value) throws java.io.IOException
Description copied from class:CodedOutputStream
Write auint64
field to the stream.- Specified by:
writeUInt64NoTag
in classCodedOutputStream
- Throws:
java.io.IOException
-
writeFixed64NoTag
public void writeFixed64NoTag(long value) throws java.io.IOException
Description copied from class:CodedOutputStream
Write afixed64
field to the stream.- Specified by:
writeFixed64NoTag
in classCodedOutputStream
- Throws:
java.io.IOException
-
writeStringNoTag
public void writeStringNoTag(java.lang.String value) throws java.io.IOException
Description copied from class:CodedOutputStream
Write astring
field to the stream.- Specified by:
writeStringNoTag
in classCodedOutputStream
- 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 classCodedOutputStream
- 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. TheByteOutput
must copyvalue
if it will not be processed prior to the return of this method call, sincevalue
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 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:
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. TheByteOutput
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 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:
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. TheByteOutput
must copyvalue
if it will not be processed prior to the return of this method call, sincevalue
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 classCodedOutputStream
- Parameters:
value
- the bytes to be written. Upon returning from this call, theposition
of this buffer will be set to thelimit
- 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. TheByteOutput
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 classCodedOutputStream
- Parameters:
value
- the bytes to be written. Upon returning from this call, theposition
of this buffer will be set to thelimit
- 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
-
-