Class CodedOutputStream

java.lang.Object
io.opentelemetry.exporter.internal.marshal.CodedOutputStream
Direct Known Subclasses:
CodedOutputStream.AbstractBufferedEncoder

public abstract class CodedOutputStream extends 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 
    Abstract base class for buffered encoders.
    private static final class 
    An CodedOutputStream that decorates an OutputStream.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final int
    The buffer size used in newInstance(OutputStream).
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    computeBoolSizeNoTag(boolean unused)
    Compute the number of bytes that would be needed to encode a bool field.
    static int
    Compute the number of bytes that would be needed to encode a bytes field.
    static int
    Compute the number of bytes that would be needed to encode a bytes field.
    static int
    computeDoubleSizeNoTag(double unused)
    Compute the number of bytes that would be needed to encode a double field, including tag.
    (package private) static int
    Compute the number of bytes that would be needed to encode an enum field.
    (package private) static int
    Compute the number of bytes that would be needed to encode a fixed32 field.
    (package private) static int
    Compute the number of bytes that would be needed to encode a fixed64 field.
    (package private) static int
    computeFloatSizeNoTag(float unused)
    Compute the number of bytes that would be needed to encode a float field, including tag.
    (package private) static int
    Compute the number of bytes that would be needed to encode an int32 field, including tag.
    static int
    Compute the number of bytes that would be needed to encode an int64 field, including tag.
    (package private) static int
     
    (package private) static int
    Compute the number of bytes that would be needed to encode an sfixed32 field.
    (package private) static int
    Compute the number of bytes that would be needed to encode an sfixed64 field.
    (package private) static int
    Compute the number of bytes that would be needed to encode an sint32 field.
    (package private) static int
    Compute the number of bytes that would be needed to encode an sint64 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
    Compute the number of bytes that would be needed to encode a uint32 field.
    (package private) static int
    Compute the number of bytes that would be needed to encode a uint64 field, including tag.
    (package private) static int
    Encode a ZigZag-encoded 32-bit value.
    (package private) static long
    Encode a ZigZag-encoded 64-bit value.
    (package private) abstract void
    Flushes the stream and forces any buffered bytes to be written.
    (package private) static CodedOutputStream
    Create a new CodedOutputStream wrapping the given OutputStream.
    (package private) abstract void
    write(byte value)
     
    (package private) abstract void
    write(byte[] value, int offset, int length)
     
    (package private) final void
    writeBoolNoTag(boolean value)
    Write a bool field to the stream.
    (package private) final void
    writeByteArrayNoTag(byte[] value)
    Write a bytes field to the stream.
    (package private) abstract void
    writeByteArrayNoTag(byte[] value, int offset, int length)
    Write a bytes field to the stream.
    (package private) abstract void
     
    (package private) final void
    writeDoubleNoTag(double value)
    Write a double field to the stream.
    (package private) final void
    writeEnumNoTag(int value)
    Write an enum field to the stream.
    (package private) abstract void
    writeFixed32NoTag(int value)
    Write a fixed32 field to the stream.
    (package private) abstract void
    writeFixed64NoTag(long value)
    Write a fixed64 field to the stream.
    (package private) final void
    writeFloatNoTag(float value)
    Write a float field to the stream.
    (package private) abstract void
    writeInt32NoTag(int value)
    Write an int32 field to the stream.
    (package private) final void
    writeInt64NoTag(long value)
    Write an int64 field to the stream.
    (package private) final void
    writeRawBytes(byte[] value)
    Write an array of bytes.
    (package private) final void
    writeSFixed32NoTag(int value)
    Write a sfixed32 field to the stream.
    (package private) final void
    writeSFixed64NoTag(long value)
    Write a sfixed64 field to the stream.
    (package private) final void
    writeSInt32NoTag(int value)
    Write a sint32 field to the stream.
    (package private) final void
    writeSInt64NoTag(long value)
    Write a sint64 field to the stream.
    (package private) abstract void
    writeUInt32NoTag(int value)
    Write a uint32 field to the stream.
    (package private) abstract void
    writeUInt64NoTag(long value)
    Write a uint64 field to the stream.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • CodedOutputStream

      private CodedOutputStream()
  • Method Details

    • newInstance

      static CodedOutputStream newInstance(OutputStream output)
      Create a new CodedOutputStream wrapping the given OutputStream.

      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 IOException
      Write an array of bytes.
      Throws:
      IOException
    • writeInt32NoTag

      abstract void writeInt32NoTag(int value) throws IOException
      Write an int32 field to the stream.
      Throws:
      IOException
    • writeUInt32NoTag

      abstract void writeUInt32NoTag(int value) throws IOException
      Write a uint32 field to the stream.
      Throws:
      IOException
    • writeSInt32NoTag

      final void writeSInt32NoTag(int value) throws IOException
      Write a sint32 field to the stream.
      Throws:
      IOException
    • writeFixed32NoTag

      abstract void writeFixed32NoTag(int value) throws IOException
      Write a fixed32 field to the stream.
      Throws:
      IOException
    • writeSFixed32NoTag

      final void writeSFixed32NoTag(int value) throws IOException
      Write a sfixed32 field to the stream.
      Throws:
      IOException
    • writeInt64NoTag

      final void writeInt64NoTag(long value) throws IOException
      Write an int64 field to the stream.
      Throws:
      IOException
    • writeUInt64NoTag

      abstract void writeUInt64NoTag(long value) throws IOException
      Write a uint64 field to the stream.
      Throws:
      IOException
    • writeSInt64NoTag

      final void writeSInt64NoTag(long value) throws IOException
      Write a sint64 field to the stream.
      Throws:
      IOException
    • writeFixed64NoTag

      abstract void writeFixed64NoTag(long value) throws IOException
      Write a fixed64 field to the stream.
      Throws:
      IOException
    • writeSFixed64NoTag

      final void writeSFixed64NoTag(long value) throws IOException
      Write a sfixed64 field to the stream.
      Throws:
      IOException
    • writeFloatNoTag

      final void writeFloatNoTag(float value) throws IOException
      Write a float field to the stream.
      Throws:
      IOException
    • writeDoubleNoTag

      final void writeDoubleNoTag(double value) throws IOException
      Write a double field to the stream.
      Throws:
      IOException
    • writeBoolNoTag

      final void writeBoolNoTag(boolean value) throws IOException
      Write a bool field to the stream.
      Throws:
      IOException
    • writeEnumNoTag

      final void writeEnumNoTag(int value) throws 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:
      IOException
    • writeByteArrayNoTag

      final void writeByteArrayNoTag(byte[] value) throws IOException
      Write a bytes field to the stream.
      Throws:
      IOException
    • write

      abstract void write(byte value) throws IOException
      Throws:
      IOException
    • write

      abstract void write(byte[] value, int offset, int length) throws IOException
      Throws:
      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 an int32 field, including tag.
    • computeUInt32SizeNoTag

      static int computeUInt32SizeNoTag(int value)
      Compute the number of bytes that would be needed to encode a uint32 field.
    • computeSInt32SizeNoTag

      static int computeSInt32SizeNoTag(int value)
      Compute the number of bytes that would be needed to encode an sint32 field.
    • computeFixed32SizeNoTag

      static int computeFixed32SizeNoTag(int unused)
      Compute the number of bytes that would be needed to encode a fixed32 field.
    • computeSFixed32SizeNoTag

      static int computeSFixed32SizeNoTag(int unused)
      Compute the number of bytes that would be needed to encode an sfixed32 field.
    • computeInt64SizeNoTag

      public static int computeInt64SizeNoTag(long value)
      Compute the number of bytes that would be needed to encode an int64 field, including tag.
    • computeUInt64SizeNoTag

      static int computeUInt64SizeNoTag(long value)
      Compute the number of bytes that would be needed to encode a uint64 field, including tag.
    • computeSInt64SizeNoTag

      static int computeSInt64SizeNoTag(long value)
      Compute the number of bytes that would be needed to encode an sint64 field.
    • computeFixed64SizeNoTag

      static int computeFixed64SizeNoTag(long unused)
      Compute the number of bytes that would be needed to encode a fixed64 field.
    • computeSFixed64SizeNoTag

      static int computeSFixed64SizeNoTag(long unused)
      Compute the number of bytes that would be needed to encode an sfixed64 field.
    • computeFloatSizeNoTag

      static int computeFloatSizeNoTag(float unused)
      Compute the number of bytes that would be needed to encode a float field, including tag.
    • computeDoubleSizeNoTag

      public static int computeDoubleSizeNoTag(double unused)
      Compute the number of bytes that would be needed to encode a double field, including tag.
    • computeBoolSizeNoTag

      public static int computeBoolSizeNoTag(boolean unused)
      Compute the number of bytes that would be needed to encode a bool 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 a bytes field.
    • computeByteBufferSizeNoTag

      public static int computeByteBufferSizeNoTag(ByteBuffer value)
      Compute the number of bytes that would be needed to encode a bytes 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 IOException
      Flushes the stream and forces any buffered bytes to be written. This does not flush the underlying OutputStream.
      Throws:
      IOException
    • writeByteArrayNoTag

      abstract void writeByteArrayNoTag(byte[] value, int offset, int length) throws IOException
      Write a bytes field to the stream.
      Throws:
      IOException
    • writeByteBufferNoTag

      abstract void writeByteBufferNoTag(ByteBuffer value) throws IOException
      Throws:
      IOException