Class LzmaCompressor

    • Method Detail

      • newFactory

        public static Supplier<LzmaCompressor> newFactory()
        Creates LZMA compressor factory with default settings.
        Returns:
        the factory.
      • newFactory

        public static Supplier<LzmaCompressor> newFactory​(int lc,
                                                          int lp,
                                                          int pb)
        Creates LZMA compressor factory with specified lc, lp, pb values and the medium dictionary size of 65536.
        Returns:
        the factory.
      • newFactory

        public static Supplier<LzmaCompressor> newFactory​(int dictionarySize)
        Creates LZMA compressor factory with specified dictionary size and default values of lc = 3, lp = 0, pb = 2.
        Returns:
        the factory.
      • newFactory

        public static Supplier<LzmaCompressor> newFactory​(int lc,
                                                          int lp,
                                                          int pb,
                                                          int dictionarySize)
        Creates LZMA compressor factory with specified lc, lp, pb values and custom dictionary size.
        Returns:
        the factory.
      • newFactory

        public static Supplier<LzmaCompressor> newFactory​(int lc,
                                                          int lp,
                                                          int pb,
                                                          int dictionarySize,
                                                          boolean endMarkerMode,
                                                          int numFastBytes)
        Creates LZMA compressor factory with specified settings.
        Parameters:
        lc - the number of "literal context" bits, available values [0, 8], default value 3.
        lp - the number of "literal position" bits, available values [0, 4], default value 0.
        pb - the number of "position" bits, available values [0, 4], default value 2.
        dictionarySize - available values [0, Integer.MAX_VALUE], default value is 65536.
        endMarkerMode - indicates should LzmaCompressor use end of stream marker or not. Note, that LzmaCompressor always sets size of uncompressed data in LZMA header, so EOS marker is unnecessary. But you may use it for better portability. For full description see "LZMA Decoding modes" section of LZMA-Specification.txt in official LZMA SDK.
        numFastBytes - available values [5, 273].
        Returns:
        the factory.
      • compress

        public Buffer compress​(Buffer in,
                               BufferAllocator allocator)
                        throws CompressionException
        Description copied from interface: Compressor
        This method will read from the input Buffer and compress into a new Buffer that will be allocated (if needed) from the BufferAllocator. This method is expected to consume all data from the input but not take ownership. The caller is responsible to release the input buffer after this method returns.
        Specified by:
        compress in interface Compressor
        Parameters:
        in - the Buffer that contains the data to be compressed.
        allocator - the BufferAllocator that is used to allocate a new buffer (if needed) to write the compressed bytes too.
        Returns:
        the Buffer that contains the compressed data. The caller of this method takes ownership of the buffer. The return value will never be null.
        Throws:
        CompressionException - thrown if an compression error was encountered or the compressor was closed already.
      • finish

        public Buffer finish​(BufferAllocator allocator)
        Description copied from interface: Compressor
        By calling this method we signal that the compression stream is marked as finish. The returned Buffer might contain a "trailer" which marks the end of the stream.
        Specified by:
        finish in interface Compressor
        Returns:
        the Buffer which represent the end of the compression stream, which might be empty if the compressor don't need a trailer to signal the end. The caller of this method takes ownership of the buffer. The return value will never be null.
      • isClosed

        public boolean isClosed()
        Description copied from interface: Compressor
        Return true if the decompressor was closed, false otherwise.
        Specified by:
        isClosed in interface Compressor
        Returns:
        true if the decompressor was closed, false otherwise.