Class CodedOutputStream
- java.lang.Object
-
- io.opentelemetry.exporter.internal.marshal.CodedOutputStream
-
- Direct Known Subclasses:
CodedOutputStream.AbstractBufferedEncoder
public abstract class CodedOutputStream extends java.lang.ObjectProtobuf wire encoder.This class is internal and is hence not for public use. Its APIs are unstable and can change at any time.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classCodedOutputStream.AbstractBufferedEncoderAbstract base class for buffered encoders.private static classCodedOutputStream.OutputStreamEncoderAnCodedOutputStreamthat decorates anOutputStream.
-
Field Summary
Fields Modifier and Type Field Description private static intDEFAULT_BUFFER_SIZEThe buffer size used innewInstance(OutputStream).private static java.lang.ThreadLocal<CodedOutputStream.OutputStreamEncoder>THREAD_LOCAL_CODED_OUTPUT_STREAM
-
Constructor Summary
Constructors Modifier Constructor Description privateCodedOutputStream()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static intcomputeBoolSizeNoTag(boolean unused)Compute the number of bytes that would be needed to encode aboolfield.static intcomputeByteArraySizeNoTag(byte[] value)Compute the number of bytes that would be needed to encode abytesfield.static intcomputeByteBufferSizeNoTag(java.nio.ByteBuffer value)Compute the number of bytes that would be needed to encode abytesfield.static intcomputeDoubleSizeNoTag(double unused)Compute the number of bytes that would be needed to encode adoublefield, including tag.(package private) static intcomputeEnumSizeNoTag(int value)Compute the number of bytes that would be needed to encode an enum field.(package private) static intcomputeFixed32SizeNoTag(int unused)Compute the number of bytes that would be needed to encode afixed32field.(package private) static intcomputeFixed64SizeNoTag(long unused)Compute the number of bytes that would be needed to encode afixed64field.(package private) static intcomputeFloatSizeNoTag(float unused)Compute the number of bytes that would be needed to encode afloatfield, including tag.(package private) static intcomputeInt32SizeNoTag(int value)Compute the number of bytes that would be needed to encode anint32field, including tag.static intcomputeInt64SizeNoTag(long value)Compute the number of bytes that would be needed to encode anint64field, including tag.(package private) static intcomputeLengthDelimitedFieldSize(int fieldLength)(package private) static intcomputeSFixed32SizeNoTag(int unused)Compute the number of bytes that would be needed to encode ansfixed32field.(package private) static intcomputeSFixed64SizeNoTag(long unused)Compute the number of bytes that would be needed to encode ansfixed64field.(package private) static intcomputeSInt32SizeNoTag(int value)Compute the number of bytes that would be needed to encode ansint32field.(package private) static intcomputeSInt64SizeNoTag(long value)Compute the number of bytes that would be needed to encode ansint64field.(package private) static intcomputeTagSize(int fieldNumber)Compute the number of bytes that would be needed to encode a tag.(package private) static intcomputeUInt32SizeNoTag(int value)Compute the number of bytes that would be needed to encode auint32field.(package private) static intcomputeUInt64SizeNoTag(long value)Compute the number of bytes that would be needed to encode auint64field, including tag.(package private) static intencodeZigZag32(int n)Encode a ZigZag-encoded 32-bit value.(package private) static longencodeZigZag64(long n)Encode a ZigZag-encoded 64-bit value.(package private) abstract voidflush()Flushes the stream and forces any buffered bytes to be written.(package private) static CodedOutputStreamnewInstance(java.io.OutputStream output)Create a newCodedOutputStreamwrapping the givenOutputStream.(package private) abstract voidwrite(byte value)(package private) abstract voidwrite(byte[] value, int offset, int length)(package private) voidwriteBoolNoTag(boolean value)Write aboolfield to the stream.(package private) voidwriteByteArrayNoTag(byte[] value)Write abytesfield to the stream.(package private) abstract voidwriteByteArrayNoTag(byte[] value, int offset, int length)Write abytesfield to the stream.(package private) abstract voidwriteByteBufferNoTag(java.nio.ByteBuffer value)(package private) voidwriteDoubleNoTag(double value)Write adoublefield to the stream.(package private) voidwriteEnumNoTag(int value)Write an enum field to the stream.(package private) abstract voidwriteFixed32NoTag(int value)Write afixed32field to the stream.(package private) abstract voidwriteFixed64NoTag(long value)Write afixed64field to the stream.(package private) voidwriteFloatNoTag(float value)Write afloatfield to the stream.(package private) abstract voidwriteInt32NoTag(int value)Write anint32field to the stream.(package private) voidwriteInt64NoTag(long value)Write anint64field to the stream.(package private) voidwriteRawBytes(byte[] value)Write an array of bytes.(package private) voidwriteSFixed32NoTag(int value)Write asfixed32field to the stream.(package private) voidwriteSFixed64NoTag(long value)Write asfixed64field to the stream.(package private) voidwriteSInt32NoTag(int value)Write asint32field to the stream.(package private) voidwriteSInt64NoTag(long value)Write asint64field to the stream.(package private) abstract voidwriteUInt32NoTag(int value)Write auint32field to the stream.(package private) abstract voidwriteUInt64NoTag(long value)Write auint64field to the stream.
-
-
-
Field Detail
-
DEFAULT_BUFFER_SIZE
private static final int DEFAULT_BUFFER_SIZE
The buffer size used innewInstance(OutputStream).
-
THREAD_LOCAL_CODED_OUTPUT_STREAM
private static final java.lang.ThreadLocal<CodedOutputStream.OutputStreamEncoder> THREAD_LOCAL_CODED_OUTPUT_STREAM
-
-
Method Detail
-
newInstance
static CodedOutputStream newInstance(java.io.OutputStream output)
Create a newCodedOutputStreamwrapping the givenOutputStream.NOTE: The provided
OutputStreamMUST NOT retain access or modify the provided byte arrays. Doing so may result in corrupted data, which would be difficult to debug.
-
writeRawBytes
final void writeRawBytes(byte[] value) throws java.io.IOExceptionWrite an array of bytes.- Throws:
java.io.IOException
-
writeInt32NoTag
abstract void writeInt32NoTag(int value) throws java.io.IOExceptionWrite anint32field to the stream.- Throws:
java.io.IOException
-
writeUInt32NoTag
abstract void writeUInt32NoTag(int value) throws java.io.IOExceptionWrite auint32field to the stream.- Throws:
java.io.IOException
-
writeSInt32NoTag
final void writeSInt32NoTag(int value) throws java.io.IOExceptionWrite asint32field to the stream.- Throws:
java.io.IOException
-
writeFixed32NoTag
abstract void writeFixed32NoTag(int value) throws java.io.IOExceptionWrite afixed32field to the stream.- Throws:
java.io.IOException
-
writeSFixed32NoTag
final void writeSFixed32NoTag(int value) throws java.io.IOExceptionWrite asfixed32field to the stream.- Throws:
java.io.IOException
-
writeInt64NoTag
final void writeInt64NoTag(long value) throws java.io.IOExceptionWrite anint64field to the stream.- Throws:
java.io.IOException
-
writeUInt64NoTag
abstract void writeUInt64NoTag(long value) throws java.io.IOExceptionWrite auint64field to the stream.- Throws:
java.io.IOException
-
writeSInt64NoTag
final void writeSInt64NoTag(long value) throws java.io.IOExceptionWrite asint64field to the stream.- Throws:
java.io.IOException
-
writeFixed64NoTag
abstract void writeFixed64NoTag(long value) throws java.io.IOExceptionWrite afixed64field to the stream.- Throws:
java.io.IOException
-
writeSFixed64NoTag
final void writeSFixed64NoTag(long value) throws java.io.IOExceptionWrite asfixed64field to the stream.- Throws:
java.io.IOException
-
writeFloatNoTag
final void writeFloatNoTag(float value) throws java.io.IOExceptionWrite afloatfield to the stream.- Throws:
java.io.IOException
-
writeDoubleNoTag
final void writeDoubleNoTag(double value) throws java.io.IOExceptionWrite adoublefield to the stream.- Throws:
java.io.IOException
-
writeBoolNoTag
final void writeBoolNoTag(boolean value) throws java.io.IOExceptionWrite aboolfield to the stream.- Throws:
java.io.IOException
-
writeEnumNoTag
final void writeEnumNoTag(int value) throws java.io.IOExceptionWrite an enum field to the stream. The provided value is the numeric value used to represent the enum value on the wire (not the enum ordinal value).- Throws:
java.io.IOException
-
writeByteArrayNoTag
final void writeByteArrayNoTag(byte[] value) throws java.io.IOExceptionWrite abytesfield to the stream.- Throws:
java.io.IOException
-
write
abstract void write(byte value) throws java.io.IOException- Throws:
java.io.IOException
-
write
abstract void write(byte[] value, int offset, int length) throws java.io.IOException- Throws:
java.io.IOException
-
computeTagSize
static int computeTagSize(int fieldNumber)
Compute the number of bytes that would be needed to encode a tag.
-
computeInt32SizeNoTag
static int computeInt32SizeNoTag(int value)
Compute the number of bytes that would be needed to encode anint32field, including tag.
-
computeUInt32SizeNoTag
static int computeUInt32SizeNoTag(int value)
Compute the number of bytes that would be needed to encode auint32field.
-
computeSInt32SizeNoTag
static int computeSInt32SizeNoTag(int value)
Compute the number of bytes that would be needed to encode ansint32field.
-
computeFixed32SizeNoTag
static int computeFixed32SizeNoTag(int unused)
Compute the number of bytes that would be needed to encode afixed32field.
-
computeSFixed32SizeNoTag
static int computeSFixed32SizeNoTag(int unused)
Compute the number of bytes that would be needed to encode ansfixed32field.
-
computeInt64SizeNoTag
public static int computeInt64SizeNoTag(long value)
Compute the number of bytes that would be needed to encode anint64field, including tag.
-
computeUInt64SizeNoTag
static int computeUInt64SizeNoTag(long value)
Compute the number of bytes that would be needed to encode auint64field, including tag.
-
computeSInt64SizeNoTag
static int computeSInt64SizeNoTag(long value)
Compute the number of bytes that would be needed to encode ansint64field.
-
computeFixed64SizeNoTag
static int computeFixed64SizeNoTag(long unused)
Compute the number of bytes that would be needed to encode afixed64field.
-
computeSFixed64SizeNoTag
static int computeSFixed64SizeNoTag(long unused)
Compute the number of bytes that would be needed to encode ansfixed64field.
-
computeFloatSizeNoTag
static int computeFloatSizeNoTag(float unused)
Compute the number of bytes that would be needed to encode afloatfield, including tag.
-
computeDoubleSizeNoTag
public static int computeDoubleSizeNoTag(double unused)
Compute the number of bytes that would be needed to encode adoublefield, including tag.
-
computeBoolSizeNoTag
public static int computeBoolSizeNoTag(boolean unused)
Compute the number of bytes that would be needed to encode aboolfield.
-
computeEnumSizeNoTag
static int computeEnumSizeNoTag(int value)
Compute the number of bytes that would be needed to encode an enum field. The provided value is the numeric value used to represent the enum value on the wire (not the enum ordinal value).
-
computeByteArraySizeNoTag
public static int computeByteArraySizeNoTag(byte[] value)
Compute the number of bytes that would be needed to encode abytesfield.
-
computeByteBufferSizeNoTag
public static int computeByteBufferSizeNoTag(java.nio.ByteBuffer value)
Compute the number of bytes that would be needed to encode abytesfield.
-
computeLengthDelimitedFieldSize
static int computeLengthDelimitedFieldSize(int fieldLength)
-
encodeZigZag32
static int encodeZigZag32(int n)
Encode a ZigZag-encoded 32-bit value. ZigZag encodes signed integers into values that can be efficiently encoded with varint. (Otherwise, negative values must be sign-extended to 64 bits to be varint encoded, thus always taking 10 bytes on the wire.)- Parameters:
n- A signed 32-bit integer.- Returns:
- An unsigned 32-bit integer, stored in a signed int because Java has no explicit unsigned support.
-
encodeZigZag64
static long encodeZigZag64(long n)
Encode a ZigZag-encoded 64-bit value. ZigZag encodes signed integers into values that can be efficiently encoded with varint. (Otherwise, negative values must be sign-extended to 64 bits to be varint encoded, thus always taking 10 bytes on the wire.)- Parameters:
n- A signed 64-bit integer.- Returns:
- An unsigned 64-bit integer, stored in a signed int because Java has no explicit unsigned support.
-
flush
abstract void flush() throws java.io.IOExceptionFlushes the stream and forces any buffered bytes to be written. This does not flush the underlying OutputStream.- Throws:
java.io.IOException
-
writeByteArrayNoTag
abstract void writeByteArrayNoTag(byte[] value, int offset, int length) throws java.io.IOExceptionWrite abytesfield to the stream.- Throws:
java.io.IOException
-
writeByteBufferNoTag
abstract void writeByteBufferNoTag(java.nio.ByteBuffer value) throws java.io.IOException- Throws:
java.io.IOException
-
-