Package com.yahoo.slime
Class BinaryFormat
java.lang.Object
com.yahoo.slime.BinaryFormat
Class for serializing Slime data into binary format, or deserializing
the binary format into a Slime object.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Slime
decode
(byte[] data) Take binary data and deserialize it into a Slime object.static Slime
decode
(byte[] data, int offset, int length) Take binary data and deserialize it into a Slime object.static byte[]
Take a Slime object and serialize it into binary format.static Compressor.Compression
encode_and_compress
(Slime slime, Compressor compressor) Take a Slime object and serialize it into binary format, and compresses it.
-
Constructor Details
-
BinaryFormat
public BinaryFormat()
-
-
Method Details
-
encode
Take a Slime object and serialize it into binary format.- Parameters:
slime
- the object which is to be serialized.- Returns:
- a new byte array with just the encoded slime.
-
encode_and_compress
Take a Slime object and serialize it into binary format, and compresses it.- Parameters:
slime
- the object which is to be serialized.compressor
- the compressor to use.- Returns:
- a new byte array with just the encoded and compressed slime.
-
decode
Take binary data and deserialize it into a Slime object. The data is assumed to be the binary representation as if obtained by a call to the @ref encode() method. If the binary data can't be deserialized without problems the returned Slime object will instead only contain the three fields "partial_result" (contains anything successfully decoded before encountering problems), "offending_input" (containing any data that could not be deserialized) and "error_message" (a string describing the problem encountered).- Parameters:
data
- the data to be deserialized.- Returns:
- a new Slime object constructed from the data.
-
decode
Take binary data and deserialize it into a Slime object. The data is assumed to be the binary representation as if obtained by a call to the @ref encode() method. If the binary data can't be deserialized without problems the returned Slime object will instead only contain the three fields "partial_result" (contains anything successfully decoded before encountering problems), "offending_input" (containing any data that could not be deserialized) and "error_message" (a string describing the problem encountered).- Parameters:
data
- array containing the data to be deserialized.offset
- where in the array to start deserializing.length
- how many bytes the deserializer is allowed to consume.- Returns:
- a new Slime object constructed from the data.
-