Class ProtobufRecord
java.lang.Object
org.openstreetmap.josm.data.protobuf.ProtobufRecord
- All Implemented Interfaces:
AutoCloseable
A protobuf record, storing the
WireType, the parsed field number, and the bytes for it.- Since:
- 17862
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate byte[]private static final byte[]private final intprivate final WireType -
Constructor Summary
ConstructorsConstructorDescriptionProtobufRecord(ByteArrayOutputStream byteArrayOutputStream, ProtobufParser parser) Create a new Protobuf record -
Method Summary
Modifier and TypeMethodDescriptiondoubleasDouble()Get as a double (WireType.SIXTY_FOUR_BIT)byte[]Get as 32 bits (WireType.THIRTY_TWO_BIT)byte[]Get as 64 bits (WireType.SIXTY_FOUR_BIT)floatasFloat()Get as a float (WireType.THIRTY_TWO_BIT)Get the signed var int (WireType#VARINT).asString()Get as a string (WireType.LENGTH_DELIMITED)Get the var int (WireType#VARINT)voidclose()byte[]getBytes()Get the raw bytes for this recordintgetField()Get the field valuegetType()Get the WireType of the data
-
Field Details
-
EMPTY_BYTES
-
type
-
field
-
bytes
-
-
Constructor Details
-
ProtobufRecord
public ProtobufRecord(ByteArrayOutputStream byteArrayOutputStream, ProtobufParser parser) throws IOException Create a new Protobuf record- Parameters:
byteArrayOutputStream- A reusable ByteArrayOutputStream to avoid unnecessary allocationsparser- The parser to use to create the record- Throws:
IOException- - if an IO error occurs
-
-
Method Details
-
asDouble
Get as a double (WireType.SIXTY_FOUR_BIT)- Returns:
- the double
-
asFixed32
Get as 32 bits (WireType.THIRTY_TWO_BIT)- Returns:
- a byte array of the 32 bits (4 bytes)
-
asFixed64
Get as 64 bits (WireType.SIXTY_FOUR_BIT)- Returns:
- a byte array of the 64 bits (8 bytes)
-
asFloat
Get as a float (WireType.THIRTY_TWO_BIT)- Returns:
- the float
-
asSignedVarInt
Get the signed var int (WireType#VARINT). These are specially encoded so that they take up less space.- Returns:
- The signed var int (
sint32orsint64)
-
asString
Get as a string (WireType.LENGTH_DELIMITED)- Returns:
- The string (encoded as
StandardCharsets.UTF_8)
-
asUnsignedVarInt
Get the var int (WireType#VARINT)- Returns:
- The var int (
int32,int64,uint32,uint64,bool,enum)
-
close
- Specified by:
closein interfaceAutoCloseable
-
getBytes
Get the raw bytes for this record- Returns:
- The bytes
-
getField
Get the field value- Returns:
- The field value
-
getType
Get the WireType of the data- Returns:
- The
WireTypeof the data
-