Class WireFormat


  • public final class WireFormat
    extends java.lang.Object
    This class is used internally by the Protocol Buffer library and generated message implementations. It is public only because those generated messages do not reside in the protobuf package. Others should not use this class directly.

    This class contains constants and helper functions useful for dealing with the Protocol Buffer wire format.

    • Constructor Detail

      • WireFormat

        private WireFormat()
    • Method Detail

      • getTagWireType

        public static int getTagWireType​(int tag)
        Given a tag value, determines the wire type (the lower 3 bits).
      • getTagFieldNumber

        public static int getTagFieldNumber​(int tag)
        Given a tag value, determines the field number (the upper 29 bits).
      • makeTag

        static int makeTag​(int fieldNumber,
                           int wireType)
        Makes a tag value given a field number and wire type.
      • readPrimitiveField

        static java.lang.Object readPrimitiveField​(CodedInputStream input,
                                                   WireFormat.FieldType type,
                                                   WireFormat.Utf8Validation utf8Validation)
                                            throws java.io.IOException
        Read a field of any primitive type for immutable messages from a CodedInputStream. Enums, groups, and embedded messages are not handled by this method.
        Parameters:
        input - The stream from which to read.
        type - Declared type of the field.
        utf8Validation - Different string UTF8 validation level for handling string fields.
        Returns:
        An object representing the field's value, of the exact type which would be returned by MessageOrBuilder.getField(Descriptors.FieldDescriptor) for this field.
        Throws:
        java.io.IOException