Class BinaryFormat

java.lang.Object
com.yahoo.slime.BinaryFormat

public class BinaryFormat extends Object
Class for serializing Slime data into binary format, or deserializing the binary format into a Slime object.
  • Constructor Details

    • BinaryFormat

      public BinaryFormat()
  • Method Details

    • encode

      public static byte[] encode(Slime slime)
      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

      public static Compressor.Compression encode_and_compress(Slime slime, Compressor compressor)
      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

      public static Slime decode(byte[] data)
      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

      public static Slime decode(byte[] data, int offset, int length)
      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.