Class CompressionManager


  • public class CompressionManager
    extends Object
    A service to get the appropriate CompressionHandler for a specified Compression algorithm.

    For details of all supported algorithms see CompressionAlgorithm.

    Since:
    2.0.0
    • Constructor Detail

      • CompressionManager

        public CompressionManager()
    • Method Detail

      • getCompressionHandler

        public CompressionHandler getCompressionHandler​(CompressionAlgorithm algorithm)
        Gets the appropriate CompressionHandler that can perform the required compression using the given compression algorithm.
        Parameters:
        algorithm - The Compression algorithm.
        Returns:
        The CompressionHandler.
      • compress

        public String compress​(CompressionAlgorithm compressionAlgorithm,
                               String data)
        Convenience method equivalent to Base64url.encode(getCompressionHandler(compressionAlgorithm).compress(data.getBytes(Utils.CHARSET))).
        Parameters:
        compressionAlgorithm - the compression algorithm to use.
        data - the data to compress.
        Returns:
        the base64url-encoded compressed data.
      • decompress

        public byte[] decompress​(CompressionAlgorithm compressionAlgorithm,
                                 String data)
        Convenience method equivalent to getCompressionHandler(compressionAlgorithm).decompress(Base64url.decode(data)).
        Parameters:
        compressionAlgorithm - the compression algorithm to use.
        data - the base64url-encoded data to decompress.
        Returns:
        the decompressed data.