public class PBinarySerializer extends PSerializer
docs/compact-binary.md for format
spec.| Modifier and Type | Class and Description |
|---|---|
protected static interface |
PBinarySerializer.DataType
DataType.
|
protected static class |
PBinarySerializer.FieldInfo
Field info data holder with convenience methods.
|
DEFAULT_ENTRY_SEP, DEFAULT_STREAM_INITIATOR, DEFAULT_STREAM_TERMINATOR| Constructor and Description |
|---|
PBinarySerializer()
Construct a serializer instance.
|
PBinarySerializer(boolean strict)
Construct a serializer instance.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
consumeMessage(net.morimekta.util.io.BinaryReader in)
Consume a message from the stream without parsing the content into a message.
|
<T> T |
deserialize(InputStream input,
PDescriptor<T> descriptor) |
protected int |
getArrayLengthBytes(int length) |
protected int |
getNumericByteLength(long value) |
protected int |
getNumericByteLengthFlag(long value) |
protected PBinarySerializer.FieldInfo |
readEntryFieldInfo(net.morimekta.util.io.BinaryReader in,
int fieldId) |
protected PBinarySerializer.FieldInfo |
readFieldInfo(net.morimekta.util.io.BinaryReader in)
Read field info from stream.
|
protected <T> T |
readFieldValue(net.morimekta.util.io.BinaryReader in,
PBinarySerializer.FieldInfo fieldInfo,
PDescriptor<T> type)
Read a field value from stream.
|
<T> int |
serialize(OutputStream output,
PDescriptor<T> descriptor,
T value) |
int |
serialize(OutputStream output,
PMessage<?> message) |
protected int |
writeBinary(net.morimekta.util.io.BinaryWriter out,
net.morimekta.util.Binary bytes) |
protected int |
writeDouble(net.morimekta.util.io.BinaryWriter out,
double value)
Write a double value to stream.
|
protected int |
writeFieldValue(net.morimekta.util.io.BinaryWriter out,
Object value)
Write a field value to stream.
|
cast, entrySeparator, streamInitiator, streamInitiatorPartOfData, streamTerminatorpublic PBinarySerializer()
public PBinarySerializer(boolean strict)
public int serialize(OutputStream output, PMessage<?> message) throws IOException, PSerializeException
serialize in class PSerializerIOExceptionPSerializeExceptionpublic <T> int serialize(OutputStream output, PDescriptor<T> descriptor, T value) throws IOException, PSerializeException
serialize in class PSerializerIOExceptionPSerializeExceptionpublic <T> T deserialize(InputStream input, PDescriptor<T> descriptor) throws PSerializeException, IOException
deserialize in class PSerializerPSerializeExceptionIOExceptionprotected void consumeMessage(net.morimekta.util.io.BinaryReader in)
throws IOException,
PSerializeException
in - Stream to read message from.IOExceptionPSerializeExceptionprotected PBinarySerializer.FieldInfo readFieldInfo(net.morimekta.util.io.BinaryReader in) throws IOException, PSerializeException
in - The stream to consume.IOExceptionPSerializeExceptionprotected PBinarySerializer.FieldInfo readEntryFieldInfo(net.morimekta.util.io.BinaryReader in, int fieldId) throws IOException, PSerializeException
IOExceptionPSerializeExceptionprotected <T> T readFieldValue(net.morimekta.util.io.BinaryReader in,
PBinarySerializer.FieldInfo fieldInfo,
PDescriptor<T> type)
throws IOException,
PSerializeException
in - The stream to consume.fieldInfo - The field info about the content.type - The type to generate content for.IOException - If unable to read from stream or invalid field type.PSerializeExceptionprotected int writeFieldValue(net.morimekta.util.io.BinaryWriter out,
Object value)
throws IOException,
PSerializeException
out - The stream to write to.value - The value to write.IOExceptionPSerializeExceptionprotected int writeDouble(net.morimekta.util.io.BinaryWriter out,
double value)
throws IOException
out - The stream to write to.value - The double value to write.IOExceptionprotected int writeBinary(net.morimekta.util.io.BinaryWriter out,
net.morimekta.util.Binary bytes)
throws IOException
out - bytes - IOExceptionprotected int getArrayLengthBytes(int length)
length - protected int getNumericByteLength(long value)
value - protected int getNumericByteLengthFlag(long value)
value - Copyright © 2016. All rights reserved.