public class BinarySerializer extends Serializer
See data definition file docs/serializer-binary.md for format
spec.
| Modifier and Type | Field and Description |
|---|---|
static String |
ALT_MEDIA_TYPE |
static BinarySerializer |
INSTANCE
An instance of the binary serializer with lenient (non-strict) parsing
ready to be used in serialization.
|
static String |
MEDIA_TYPE |
DEFAULT_STRICT| Constructor and Description |
|---|
BinarySerializer()
Construct a serializer instance.
|
BinarySerializer(boolean readStrict)
Construct a serializer instance.
|
BinarySerializer(boolean readStrict,
boolean versioned)
Construct a serializer instance.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
binaryProtocol() |
<Message extends PMessage<Message>> |
deserialize(InputStream input,
PMessageDescriptor<Message> descriptor)
Deserialize a message.
|
<Message extends PMessage<Message>> |
deserialize(InputStream is,
PService service)
Deserialize a service call.
|
String |
mediaType() |
static <Message extends PMessage<Message>> |
parseBinary(net.morimekta.util.Binary binary,
PMessageDescriptor<Message> descriptor) |
<Message extends PMessage<Message>> |
serialize(OutputStream os,
PMessageOrBuilder<Message> message)
Serialize a message.
|
<Message extends PMessage<Message>> |
serialize(OutputStream os,
PServiceCall<Message> call)
Serialize a service call.
|
static <Message extends PMessage<Message>> |
toBinary(Message message) |
void |
verifyEndOfContent(InputStream input)
Verify that the input stream does not contain any more readable content and
close the stream.
|
isRequestCallType, toStringpublic static final String MEDIA_TYPE
public static final String ALT_MEDIA_TYPE
public static final BinarySerializer INSTANCE
Serializable
reading and writing.public BinarySerializer()
public BinarySerializer(boolean readStrict)
readStrict - If the serializer should fail on bad reading.public BinarySerializer(boolean readStrict,
boolean versioned)
readStrict - If the serializer should fail on reading mismatched data.versioned - If the serializer should use the versioned service call format.public static <Message extends PMessage<Message>> net.morimekta.util.Binary toBinary(@Nonnull Message message)
public static <Message extends PMessage<Message>> Message parseBinary(net.morimekta.util.Binary binary, PMessageDescriptor<Message> descriptor)
public boolean binaryProtocol()
binaryProtocol in class Serializerpublic void verifyEndOfContent(@Nonnull InputStream input) throws IOException
SerializerverifyEndOfContent in class Serializerinput - The input stream to check.IOException - If unable to read from stream or stream contains meaningful content.@Nonnull public String mediaType()
mediaType in class Serializerpublic <Message extends PMessage<Message>> int serialize(@Nonnull OutputStream os, @Nonnull PMessageOrBuilder<Message> message) throws IOException
Serializerserialize in class SerializerMessage - The message type.os - The output stream to write to.message - The message to write.IOException - If writing or serialization failed.public <Message extends PMessage<Message>> int serialize(@Nonnull OutputStream os, @Nonnull PServiceCall<Message> call) throws IOException
Serializerserialize in class SerializerMessage - The message type contained in the service call.os - The output stream to write to.call - The service call to write.IOException - If writing or serialization failed.@Nonnull public <Message extends PMessage<Message>> Message deserialize(@Nonnull InputStream input, @Nonnull PMessageDescriptor<Message> descriptor) throws IOException
Serializerdeserialize in class SerializerMessage - The message type.input - The input stream to read from.descriptor - The descriptor of the message to read.IOException - If reading or deserialization failed.@Nonnull public <Message extends PMessage<Message>> PServiceCall<Message> deserialize(@Nonnull InputStream is, @Nonnull PService service) throws IOException
Serializerdeserialize in class SerializerMessage - The message type contained in the returned service call.is - The input stream to read from.service - The service definition to read for.IOException - If reading or deserialization failed.Copyright © 2015–2020 morimekta.net. All rights reserved.