Class LzmaArchiveSettings


  • public class LzmaArchiveSettings
    extends Object

    Settings for lzma archive.

    The Lempel–Ziv–Markov chain algorithm (LZMA) is an algorithm used to perform lossless data compression. This algorithm uses a dictionary compression scheme somewhat similar to the LZ77 algorithm and features a high compression ratio and a variable compression-dictionary size.

    See more: Lempel–Ziv–Markov chain algorithm

    • Constructor Detail

      • LzmaArchiveSettings

        public LzmaArchiveSettings()

        Initializes a new instance of the LzmaArchiveSettings class with default dictionary size, equals to 16 megabytes, number of fast bytes equal to 32 and literal context bits equal to 3.

        
             LzmaArchiveSettings settings = new LzmaArchiveSettings();
             settings.setDictionarySize(1048576);
             try (LzmaArchive archive = new LzmaArchive(settings)) {
                 archive.setSource("data.bin");
                 archive.save(lzmaFile);
             }
         
    • Method Detail

      • getCompressionProgressed

        public Event<ProgressEventArgs> getCompressionProgressed()

        Gets an event that is raised when a portion of raw stream compressed.

        
            lzmaArchiveSettings.setCompressionProgressed(new Event<ProgressEventArgs>() {
                public void invoke(Object sender, ProgressEventArgs progressEventArgs) {
                    int percent = (int) ((100 * (long) progressEventArgs.getProceededBytes()) / entrySourceFile.length());
                }
            });
         
        Returns:
        an event that is raised when a portion of raw stream compressed
      • setCompressionProgressed

        public void setCompressionProgressed​(Event<ProgressEventArgs> value)

        Sets an event that is raised when a portion of raw stream compressed.

        
            lzmaArchiveSettings.setCompressionProgressed(new Event<ProgressEventArgs>() {
                public void invoke(Object sender, ProgressEventArgs progressEventArgs) {
                    int percent = (int) ((100 * (long) progressEventArgs.getProceededBytes()) / entrySourceFile.length());
                }
            });
         
        Parameters:
        value - an event that is raised when a portion of raw stream compressed
      • getDictionarySize

        public final int getDictionarySize()

        Dictionary (history buffer) size indicates how many bytes of the recently processed uncompressed data are kept in memory. If not set, will be chosen accordingly to entry size.

        The bigger the dictionary, usually the better the compression ratio is - but dictionaries larger than the uncompressed data are a waste of RAM. The disctionary size of LZMA archive must be either a power of two (2^n) or three times a power of two (3*2^n).

        Returns:
        Dictionary (history buffer) size.
      • setDictionarySize

        public final void setDictionarySize​(int value)

        Dictionary (history buffer) size indicates how many bytes of the recently processed uncompressed data are kept in memory. If not set, will be chosen accordingly to entry size.

        The bigger the dictionary, usually the better the compression ratio is - but dictionaries larger than the uncompressed data are a waste of RAM. The disctionary size of LZMA archive must be either a power of two (2^n) or three times a power of two (3*2^n).

        Parameters:
        value - Dictionary (history buffer) size.
      • getNumberOfFastBytes

        public final int getNumberOfFastBytes()

        Gets the number of bytes used for fast match searching in the LZMA algorithm.

        A higher value allows the compressor to search longer matches, which can improve the compression ratio slightly but slows down compression.

        Returns:
        the number of bytes used for fast match searching in the LZMA algorithm.
      • setNumberOfFastBytes

        public final void setNumberOfFastBytes​(int value)

        Sets the number of bytes used for fast match searching in the LZMA algorithm.

        A higher value allows the compressor to search longer matches, which can improve the compression ratio slightly but slows down compression.

        Parameters:
        value - the number of bytes used for fast match searching in the LZMA algorithm.
      • getLiteralContextBits

        public final int getLiteralContextBits()

        Gets the number of literal context bits.

        Literal Context Bits define how many of the most significant bits of the previous uncompressed byte are used to predict the bits of the next literal byte. Must be from 0 to 8.

        Returns:
        the number of literal context bits.
      • setLiteralContextBits

        public final void setLiteralContextBits​(int value)

        Sets the number of literal context bits.

        Literal Context Bits define how many of the most significant bits of the previous uncompressed byte are used to predict the bits of the next literal byte. Must be from 0 to 8.

        Parameters:
        value - the number of literal context bits.