public class

BinaryFormatter

extends Object
java.lang.Object
   ↳ com.openxc.messages.formatters.BinaryFormatter

Class Overview

A formatter for serializing and deserializing Protocol Buffers, i.e. the OpenXC binary message format.

Summary

Public Constructors
BinaryFormatter()
Public Methods
static VehicleMessage deserialize(InputStream data)
Deserialize a single vehicle message from the input stream.
static MessageLite preSerialize(VehicleMessage message)
Serialize a VehicleMessage into an intermediate protobuf object.
static byte[] serialize(VehicleMessage message)
Serialize a VehicleMessage into a byte array.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public BinaryFormatter ()

Public Methods

public static VehicleMessage deserialize (InputStream data)

Deserialize a single vehicle message from the input stream.

Parameters
data The stream that should include protobuf-encoded vehicle messages.
Returns
  • the deserialized VehicleMessage
Throws
UnrecognizedMessageTypeException if a message could not be deserialized.

public static MessageLite preSerialize (VehicleMessage message)

Serialize a VehicleMessage into an intermediate protobuf object. This used to write delimited, serialized messages to a stream for the binary format

public static byte[] serialize (VehicleMessage message)

Serialize a VehicleMessage into a byte array.

Parameters
message the VehicleMessage to serialize.
Returns
  • the message serialized to bytes.
Throws
SerializationException if there was an error with serializing the message.