Class CodedOutputStream
- java.lang.Object
-
- io.opentelemetry.exporter.internal.marshal.CodedOutputStream
-
- Direct Known Subclasses:
CodedOutputStream.AbstractBufferedEncoder
public abstract class CodedOutputStream extends java.lang.Object
Protobuf 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 class
CodedOutputStream.AbstractBufferedEncoder
Abstract base class for buffered encoders.private static class
CodedOutputStream.OutputStreamEncoder
AnCodedOutputStream
that decorates anOutputStream
.
-
Field Summary
Fields Modifier and Type Field Description private static int
DEFAULT_BUFFER_SIZE
The buffer size used innewInstance(OutputStream)
.private static java.lang.ThreadLocal<CodedOutputStream.OutputStreamEncoder>
THREAD_LOCAL_CODED_OUTPUT_STREAM
-
Constructor Summary
Constructors Modifier Constructor Description private
CodedOutputStream()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static int
computeBoolSizeNoTag(boolean unused)
Compute the number of bytes that would be needed to encode abool
field.static int
computeByteArraySizeNoTag(byte[] value)
Compute the number of bytes that would be needed to encode abytes
field.static int
computeByteBufferSizeNoTag(java.nio.ByteBuffer value)
Compute the number of bytes that would be needed to encode abytes
field.static int
computeDoubleSizeNoTag(double unused)
Compute the number of bytes that would be needed to encode adouble
field, including tag.(package private) static int
computeEnumSizeNoTag(int value)
Compute the number of bytes that would be needed to encode an enum field.(package private) static int
computeFixed32SizeNoTag(int unused)
Compute the number of bytes that would be needed to encode afixed32
field.(package private) static int
computeFixed64SizeNoTag(long unused)
Compute the number of bytes that would be needed to encode afixed64
field.(package private) static int
computeFloatSizeNoTag(float unused)
Compute the number of bytes that would be needed to encode afloat
field, including tag.(package private) static int
computeInt32SizeNoTag(int value)
Compute the number of bytes that would be needed to encode anint32
field, including tag.static int
computeInt64SizeNoTag(long value)
Compute the number of bytes that would be needed to encode anint64
field, including tag.(package private) static int
computeLengthDelimitedFieldSize(int fieldLength)
(package private) static int
computeSFixed32SizeNoTag(int unused)
Compute the number of bytes that would be needed to encode ansfixed32
field.(package private) static int
computeSFixed64SizeNoTag(long unused)
Compute the number of bytes that would be needed to encode ansfixed64
field.(package private) static int
computeSInt32SizeNoTag(int value)
Compute the number of bytes that would be needed to encode ansint32
field.(package private) static int
computeSInt64SizeNoTag(long value)
Compute the number of bytes that would be needed to encode ansint64
field.(package private) static int
computeTagSize(int fieldNumber)
Compute the number of bytes that would be needed to encode a tag.(package private) static int
computeUInt32SizeNoTag(int value)
Compute the number of bytes that would be needed to encode auint32
field.(package private) static int
computeUInt64SizeNoTag(long value)
Compute the number of bytes that would be needed to encode auint64
field, including tag.(package private) static int
encodeZigZag32(int n)
Encode a ZigZag-encoded 32-bit value.(package private) static long
encodeZigZag64(long n)
Encode a ZigZag-encoded 64-bit value.(package private) abstract void
flush()
Flushes the stream and forces any buffered bytes to be written.(package private) static CodedOutputStream
newInstance(java.io.OutputStream output)
Create a newCodedOutputStream
wrapping the givenOutputStream
.(package private) abstract void
write(byte value)
(package private) abstract void
write(byte[] value, int offset, int length)
(package private) void
writeBoolNoTag(boolean value)
Write abool
field to the stream.(package private) void
writeByteArrayNoTag(byte[] value)
Write abytes
field to the stream.(package private) abstract void
writeByteArrayNoTag(byte[] value, int offset, int length)
Write abytes
field to the stream.(package private) abstract void
writeByteBufferNoTag(java.nio.ByteBuffer value)
(package private) void
writeDoubleNoTag(double value)
Write adouble
field to the stream.(package private) void
writeEnumNoTag(int value)
Write an enum field to the stream.(package private) abstract void
writeFixed32NoTag(int value)
Write afixed32
field to the stream.(package private) abstract void
writeFixed64NoTag(long value)
Write afixed64
field to the stream.(package private) void
writeFloatNoTag(float value)
Write afloat
field to the stream.(package private) abstract void
writeInt32NoTag(int value)
Write anint32
field to the stream.(package private) void
writeInt64NoTag(long value)
Write anint64
field to the stream.(package private) void
writeRawBytes(byte[] value)
Write an array of bytes.(package private) void
writeSFixed32NoTag(int value)
Write asfixed32
field to the stream.(package private) void
writeSFixed64NoTag(long value)
Write asfixed64
field to the stream.(package private) void
writeSInt32NoTag(int value)
Write asint32
field to the stream.(package private) void
writeSInt64NoTag(long value)
Write asint64
field to the stream.(package private) abstract void
writeUInt32NoTag(int value)
Write auint32
field to the stream.(package private) abstract void
writeUInt64NoTag(long value)
Write auint64
field 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 newCodedOutputStream
wrapping the givenOutputStream
.NOTE: The provided
OutputStream
MUST 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.IOException
Write an array of bytes.- Throws:
java.io.IOException
-
writeInt32NoTag
abstract void writeInt32NoTag(int value) throws java.io.IOException
Write anint32
field to the stream.- Throws:
java.io.IOException
-
writeUInt32NoTag
abstract void writeUInt32NoTag(int value) throws java.io.IOException
Write auint32
field to the stream.- Throws:
java.io.IOException
-
writeSInt32NoTag
final void writeSInt32NoTag(int value) throws java.io.IOException
Write asint32
field to the stream.- Throws:
java.io.IOException
-
writeFixed32NoTag
abstract void writeFixed32NoTag(int value) throws java.io.IOException
Write afixed32
field to the stream.- Throws:
java.io.IOException
-
writeSFixed32NoTag
final void writeSFixed32NoTag(int value) throws java.io.IOException
Write asfixed32
field to the stream.- Throws:
java.io.IOException
-
writeInt64NoTag
final void writeInt64NoTag(long value) throws java.io.IOException
Write anint64
field to the stream.- Throws:
java.io.IOException
-
writeUInt64NoTag
abstract void writeUInt64NoTag(long value) throws java.io.IOException
Write auint64
field to the stream.- Throws:
java.io.IOException
-
writeSInt64NoTag
final void writeSInt64NoTag(long value) throws java.io.IOException
Write asint64
field to the stream.- Throws:
java.io.IOException
-
writeFixed64NoTag
abstract void writeFixed64NoTag(long value) throws java.io.IOException
Write afixed64
field to the stream.- Throws:
java.io.IOException
-
writeSFixed64NoTag
final void writeSFixed64NoTag(long value) throws java.io.IOException
Write asfixed64
field to the stream.- Throws:
java.io.IOException
-
writeFloatNoTag
final void writeFloatNoTag(float value) throws java.io.IOException
Write afloat
field to the stream.- Throws:
java.io.IOException
-
writeDoubleNoTag
final void writeDoubleNoTag(double value) throws java.io.IOException
Write adouble
field to the stream.- Throws:
java.io.IOException
-
writeBoolNoTag
final void writeBoolNoTag(boolean value) throws java.io.IOException
Write abool
field to the stream.- Throws:
java.io.IOException
-
writeEnumNoTag
final void writeEnumNoTag(int value) throws java.io.IOException
Write 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.IOException
Write abytes
field 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 anint32
field, including tag.
-
computeUInt32SizeNoTag
static int computeUInt32SizeNoTag(int value)
Compute the number of bytes that would be needed to encode auint32
field.
-
computeSInt32SizeNoTag
static int computeSInt32SizeNoTag(int value)
Compute the number of bytes that would be needed to encode ansint32
field.
-
computeFixed32SizeNoTag
static int computeFixed32SizeNoTag(int unused)
Compute the number of bytes that would be needed to encode afixed32
field.
-
computeSFixed32SizeNoTag
static int computeSFixed32SizeNoTag(int unused)
Compute the number of bytes that would be needed to encode ansfixed32
field.
-
computeInt64SizeNoTag
public static int computeInt64SizeNoTag(long value)
Compute the number of bytes that would be needed to encode anint64
field, including tag.
-
computeUInt64SizeNoTag
static int computeUInt64SizeNoTag(long value)
Compute the number of bytes that would be needed to encode auint64
field, including tag.
-
computeSInt64SizeNoTag
static int computeSInt64SizeNoTag(long value)
Compute the number of bytes that would be needed to encode ansint64
field.
-
computeFixed64SizeNoTag
static int computeFixed64SizeNoTag(long unused)
Compute the number of bytes that would be needed to encode afixed64
field.
-
computeSFixed64SizeNoTag
static int computeSFixed64SizeNoTag(long unused)
Compute the number of bytes that would be needed to encode ansfixed64
field.
-
computeFloatSizeNoTag
static int computeFloatSizeNoTag(float unused)
Compute the number of bytes that would be needed to encode afloat
field, including tag.
-
computeDoubleSizeNoTag
public static int computeDoubleSizeNoTag(double unused)
Compute the number of bytes that would be needed to encode adouble
field, including tag.
-
computeBoolSizeNoTag
public static int computeBoolSizeNoTag(boolean unused)
Compute the number of bytes that would be needed to encode abool
field.
-
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 abytes
field.
-
computeByteBufferSizeNoTag
public static int computeByteBufferSizeNoTag(java.nio.ByteBuffer value)
Compute the number of bytes that would be needed to encode abytes
field.
-
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.IOException
Flushes 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.IOException
Write abytes
field to the stream.- Throws:
java.io.IOException
-
writeByteBufferNoTag
abstract void writeByteBufferNoTag(java.nio.ByteBuffer value) throws java.io.IOException
- Throws:
java.io.IOException
-
-