Class JsonLzfCodec

java.lang.Object
com.github.cafapi.common.codecs.jsonlzf.JsonLzfCodec
All Implemented Interfaces:
Codec, Decoder

public class JsonLzfCodec extends Object implements Codec
Implementation of Codec that supports serialisation and deserialisation to and form JSON format that itself is compressed with a high-speed LZF algorithm. In some crude tests, this was resulting in data that was approximately 60% of the original JSON size with negligible performance impact.
  • Constructor Details

    • JsonLzfCodec

      public JsonLzfCodec()
  • Method Details

    • deserialise

      public <T> T deserialise(byte[] data, Class<T> clazz, DecodeMethod method) throws CodecException
      Description copied from interface: Codec
      Deserialise the given data into the specified class.
      Specified by:
      deserialise in interface Codec
      Type Parameters:
      T - the class the serialised data represents
      Parameters:
      data - the serialised data
      clazz - the class the serialised data represents
      method - specifies whether to use strict or lenient decoding during deserialisation
      Returns:
      an instance of the class specified represented by the data
      Throws:
      CodecException - if the data could not be deserialised
    • deserialise

      public <T> T deserialise(InputStream stream, Class<T> clazz, DecodeMethod method) throws CodecException
      Description copied from interface: Codec
      Deserialise the given data into the specified class using the default decode method.
      Specified by:
      deserialise in interface Codec
      Type Parameters:
      T - the class the serialised data represents
      Parameters:
      stream - the serialised data as a stream
      clazz - the class the serialised data represents
      method - specifies whether to use strict or lenient decoding during deserialisation
      Returns:
      an instance of the class specified represented by the data
      Throws:
      CodecException - if the data could not be deserialised
    • serialise

      public byte[] serialise(Object object) throws CodecException
      Description copied from interface: Codec
      Serialise the given object into a byte data form.
      Specified by:
      serialise in interface Codec
      Parameters:
      object - the object to serialise
      Returns:
      the serialised data of the given object
      Throws:
      CodecException - if the object could not be serialised
    • getMapper

      protected com.fasterxml.jackson.databind.ObjectMapper getMapper(DecodeMethod method)