Interface ProtoValue

All Known Implementing Classes:
ProtoValue.Bytes, ProtoValue.Fixed32, ProtoValue.Fixed64, ProtoValue.Group, ProtoValue.Message, ProtoValue.Packed, ProtoValue.Text, ProtoValue.Varint

One value of a protobuf field: what its wire type says, plus how a length-delimited value was understood. Without a schema, Protobuf.decode(byte[]) guesses whether length-delimited bytes are ProtoValue.Text, a nested ProtoValue.Message or plain ProtoValue.Bytes; with one, the declared field types decide, and repeated scalars sent packed become ProtoValue.Packed.

Every value re-encodes to the wire form it was read from (Protobuf.encode(ProtoMessage)).

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final record 
    Length-delimited bytes (wire type 2) that are neither text nor a message, or that a schema declares as bytes.
    static final record 
    Four bytes (wire type 5): fixed32, sfixed32 or float.
    static final record 
    Eight bytes (wire type 1): fixed64, sfixed64 or double.
    static final record 
    A group (wire types 3 and 4), proto2's deprecated way of nesting a message.
    static final record 
    A nested message (wire type 2).
    static final record 
    A packed repeated scalar field (wire type 2): several ProtoValue.Varint, ProtoValue.Fixed32 or ProtoValue.Fixed64 values in one length-delimited value.
    static final record 
    Length-delimited UTF-8 text (wire type 2): a string, or bytes that read as text.
    static final record 
    A varint (wire type 0): int32, int64, uint32, uint64, sint32, sint64, bool or an enum.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Wire type 4: the end of a group.
    static final int
    Wire type 5: four little-endian bytes.
    static final int
    Wire type 1: eight little-endian bytes.
    static final int
    Wire type 2: a length, then that many bytes.
    static final int
    Wire type 3: the start of a group.
    static final int
    Wire type 0: base-128 varint.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the wire type this value is encoded with.
  • Field Details

    • WIRE_VARINT

      static final int WIRE_VARINT
      Wire type 0: base-128 varint.
      See Also:
    • WIRE_FIXED64

      static final int WIRE_FIXED64
      Wire type 1: eight little-endian bytes.
      See Also:
    • WIRE_LEN

      static final int WIRE_LEN
      Wire type 2: a length, then that many bytes.
      See Also:
    • WIRE_START_GROUP

      static final int WIRE_START_GROUP
      Wire type 3: the start of a group.
      See Also:
    • WIRE_END_GROUP

      static final int WIRE_END_GROUP
      Wire type 4: the end of a group.
      See Also:
    • WIRE_FIXED32

      static final int WIRE_FIXED32
      Wire type 5: four little-endian bytes.
      See Also:
  • Method Details

    • wireType

      int wireType()
      Returns the wire type this value is encoded with.
      Returns:
      the wire type this value is encoded with