private static final class CodedOutputStream.ByteOutputEncoder extends CodedOutputStream.AbstractBufferedEncoder
CodedOutputStream that decorates a ByteOutput. It internal buffer only to
support string encoding operations. All other writes are just passed through to the
ByteOutput.CodedOutputStream.OutOfSpaceException| Modifier and Type | Field and Description |
|---|---|
private ByteOutput |
out |
buffer, limit, position, totalBytesWrittenDEFAULT_BUFFER_SIZE, LITTLE_ENDIAN_32_SIZE| Constructor and Description |
|---|
ByteOutputEncoder(ByteOutput out,
int bufferSize) |
| Modifier and Type | Method and 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 a
bool field, including tag, to the stream. |
void |
writeByteArray(int fieldNumber,
byte[] value)
Write a
bytes field, including tag, to the stream. |
void |
writeByteArray(int fieldNumber,
byte[] value,
int offset,
int length)
Write a
bytes field, including tag, to the stream. |
void |
writeByteArrayNoTag(byte[] value,
int offset,
int length)
Write a
bytes field to the stream. |
void |
writeByteBuffer(int fieldNumber,
java.nio.ByteBuffer value)
Write a
bytes field, including tag, to the stream. |
void |
writeBytes(int fieldNumber,
ByteString value)
Write a
bytes field, including tag, to the stream. |
void |
writeBytesNoTag(ByteString value)
Write a
bytes field to the stream. |
void |
writeFixed32(int fieldNumber,
int value)
Write a
fixed32 field, including tag, to the stream. |
void |
writeFixed32NoTag(int value)
Write a
fixed32 field to the stream. |
void |
writeFixed64(int fieldNumber,
long value)
Write a
fixed64 field, including tag, to the stream. |
void |
writeFixed64NoTag(long value)
Write a
fixed64 field to the stream. |
void |
writeInt32(int fieldNumber,
int value)
Write an
int32 field, including tag, to the stream. |
void |
writeInt32NoTag(int value)
Write an
int32 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.
|
void |
writeMessageNoTag(MessageLite value)
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 a
string field, including tag, to the stream. |
void |
writeStringNoTag(java.lang.String value)
Write a
string field to the stream. |
void |
writeTag(int fieldNumber,
int wireType)
Encode and write a tag.
|
void |
writeUInt32(int fieldNumber,
int value)
Write a
uint32 field, including tag, to the stream. |
void |
writeUInt32NoTag(int value)
Write a
uint32 field to the stream. |
void |
writeUInt64(int fieldNumber,
long value)
Write a
uint64 field, including tag, to the stream. |
void |
writeUInt64NoTag(long value)
Write a
uint64 field to the stream. |
buffer, bufferFixed32NoTag, bufferFixed64NoTag, bufferInt32NoTag, bufferTag, bufferUInt32NoTag, bufferUInt64NoTag, getTotalBytesWritten, spaceLeftcheckNoSpaceLeft, computeBoolSize, computeBoolSizeNoTag, computeByteArraySize, computeByteArraySizeNoTag, computeByteBufferSize, computeByteBufferSizeNoTag, computeBytesSize, computeBytesSizeNoTag, computeDoubleSize, computeDoubleSizeNoTag, computeEnumSize, computeEnumSizeNoTag, computeFixed32Size, computeFixed32SizeNoTag, computeFixed64Size, computeFixed64SizeNoTag, computeFloatSize, computeFloatSizeNoTag, computeGroupSize, computeGroupSizeNoTag, computeInt32Size, computeInt32SizeNoTag, computeInt64Size, computeInt64SizeNoTag, computeLazyFieldMessageSetExtensionSize, computeLazyFieldSize, computeLazyFieldSizeNoTag, computeLengthDelimitedFieldSize, computeMessageSetExtensionSize, computeMessageSize, 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, writeGroupNoTag, writeInt64, writeInt64NoTag, writeRawByte, writeRawByte, writeRawBytes, writeRawBytes, writeRawBytes, writeRawLittleEndian32, writeRawLittleEndian64, writeRawVarint32, writeRawVarint64, writeSFixed32, writeSFixed32NoTag, writeSFixed64, writeSFixed64NoTag, writeSInt32, writeSInt32NoTag, writeSInt64, writeSInt64NoTagprivate final ByteOutput out
ByteOutputEncoder(ByteOutput out, int bufferSize)
public void writeTag(int fieldNumber,
int wireType)
throws java.io.IOException
CodedOutputStreamwriteTag in class CodedOutputStreamjava.io.IOExceptionpublic void writeInt32(int fieldNumber,
int value)
throws java.io.IOException
CodedOutputStreamint32 field, including tag, to the stream.writeInt32 in class CodedOutputStreamjava.io.IOExceptionpublic void writeUInt32(int fieldNumber,
int value)
throws java.io.IOException
CodedOutputStreamuint32 field, including tag, to the stream.writeUInt32 in class CodedOutputStreamjava.io.IOExceptionpublic void writeFixed32(int fieldNumber,
int value)
throws java.io.IOException
CodedOutputStreamfixed32 field, including tag, to the stream.writeFixed32 in class CodedOutputStreamjava.io.IOExceptionpublic void writeUInt64(int fieldNumber,
long value)
throws java.io.IOException
CodedOutputStreamuint64 field, including tag, to the stream.writeUInt64 in class CodedOutputStreamjava.io.IOExceptionpublic void writeFixed64(int fieldNumber,
long value)
throws java.io.IOException
CodedOutputStreamfixed64 field, including tag, to the stream.writeFixed64 in class CodedOutputStreamjava.io.IOExceptionpublic void writeBool(int fieldNumber,
boolean value)
throws java.io.IOException
CodedOutputStreambool field, including tag, to the stream.writeBool in class CodedOutputStreamjava.io.IOExceptionpublic void writeString(int fieldNumber,
java.lang.String value)
throws java.io.IOException
CodedOutputStreamstring field, including tag, to the stream.writeString in class CodedOutputStreamjava.io.IOExceptionpublic void writeBytes(int fieldNumber,
ByteString value)
throws java.io.IOException
CodedOutputStreambytes field, including tag, to the stream.writeBytes in class CodedOutputStreamjava.io.IOExceptionpublic void writeByteArray(int fieldNumber,
byte[] value)
throws java.io.IOException
CodedOutputStreambytes field, including tag, to the stream.writeByteArray in class CodedOutputStreamjava.io.IOExceptionpublic void writeByteArray(int fieldNumber,
byte[] value,
int offset,
int length)
throws java.io.IOException
CodedOutputStreambytes field, including tag, to the stream.writeByteArray in class CodedOutputStreamjava.io.IOExceptionpublic void writeByteBuffer(int fieldNumber,
java.nio.ByteBuffer value)
throws java.io.IOException
CodedOutputStreambytes 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()).writeByteBuffer in class CodedOutputStreamjava.io.IOExceptionpublic void writeBytesNoTag(ByteString value) throws java.io.IOException
CodedOutputStreambytes field to the stream.writeBytesNoTag in class CodedOutputStreamjava.io.IOExceptionpublic void writeByteArrayNoTag(byte[] value,
int offset,
int length)
throws java.io.IOException
CodedOutputStreambytes field to the stream. Visible for testing.writeByteArrayNoTag in class CodedOutputStreamjava.io.IOExceptionpublic void writeRawBytes(java.nio.ByteBuffer value)
throws java.io.IOException
CodedOutputStreamwriteRawBytes(byteBuffer.slice()).writeRawBytes in class CodedOutputStreamjava.io.IOExceptionpublic void writeMessage(int fieldNumber,
MessageLite value)
throws java.io.IOException
CodedOutputStreamwriteMessage in class CodedOutputStreamjava.io.IOExceptionpublic void writeMessageSetExtension(int fieldNumber,
MessageLite value)
throws java.io.IOException
CodedOutputStreamwriteMessageSetExtension in class CodedOutputStreamjava.io.IOExceptionpublic void writeRawMessageSetExtension(int fieldNumber,
ByteString value)
throws java.io.IOException
CodedOutputStreamwriteRawMessageSetExtension in class CodedOutputStreamjava.io.IOExceptionpublic void writeMessageNoTag(MessageLite value) throws java.io.IOException
CodedOutputStreamwriteMessageNoTag in class CodedOutputStreamjava.io.IOExceptionpublic void write(byte value)
throws java.io.IOException
ByteOutputwrite in class CodedOutputStreamvalue - the byte to be writtenjava.io.IOException - thrown if an error occurred while writingpublic void writeInt32NoTag(int value)
throws java.io.IOException
CodedOutputStreamint32 field to the stream.writeInt32NoTag in class CodedOutputStreamjava.io.IOExceptionpublic void writeUInt32NoTag(int value)
throws java.io.IOException
CodedOutputStreamuint32 field to the stream.writeUInt32NoTag in class CodedOutputStreamjava.io.IOExceptionpublic void writeFixed32NoTag(int value)
throws java.io.IOException
CodedOutputStreamfixed32 field to the stream.writeFixed32NoTag in class CodedOutputStreamjava.io.IOExceptionpublic void writeUInt64NoTag(long value)
throws java.io.IOException
CodedOutputStreamuint64 field to the stream.writeUInt64NoTag in class CodedOutputStreamjava.io.IOExceptionpublic void writeFixed64NoTag(long value)
throws java.io.IOException
CodedOutputStreamfixed64 field to the stream.writeFixed64NoTag in class CodedOutputStreamjava.io.IOExceptionpublic void writeStringNoTag(java.lang.String value)
throws java.io.IOException
CodedOutputStreamstring field to the stream.writeStringNoTag in class CodedOutputStreamjava.io.IOExceptionpublic void flush()
throws java.io.IOException
CodedOutputStreamflush in class CodedOutputStreamjava.io.IOExceptionpublic void write(byte[] value,
int offset,
int length)
throws java.io.IOException
ByteOutputByteOutput 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.
write in class CodedOutputStreamvalue - the bytes to be writtenoffset - the offset of the start of the writable rangelength - the number of bytes to write starting from offsetjava.io.IOException - thrown if an error occurred while writingpublic void writeLazy(byte[] value,
int offset,
int length)
throws java.io.IOException
ByteOutputByteOutput 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.
writeLazy in class CodedOutputStreamvalue - the bytes to be writtenoffset - the offset of the start of the writable rangelength - the number of bytes to write starting from offsetjava.io.IOException - thrown if an error occurred while writingpublic void write(java.nio.ByteBuffer value)
throws java.io.IOException
ByteOutputByteOutput 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.
write in class CodedOutputStreamvalue - the bytes to be written. Upon returning from this call, the position of
this buffer will be set to the limitjava.io.IOException - thrown if an error occurred while writingpublic void writeLazy(java.nio.ByteBuffer value)
throws java.io.IOException
ByteOutputByteOutput 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.
writeLazy in class CodedOutputStreamvalue - the bytes to be written. Upon returning from this call, the position of
this buffer will be set to the limitjava.io.IOException - thrown if an error occurred while writingprivate void flushIfNotAvailable(int requiredSize)
throws java.io.IOException
java.io.IOExceptionprivate void doFlush()
throws java.io.IOException
java.io.IOException