Class LZMACompressor

  • All Implemented Interfaces:
    com.google.gwt.core.client.Scheduler.RepeatingCommand
    Direct Known Subclasses:
    LZMAByteArrayCompressor

    public class LZMACompressor
    extends Object
    implements com.google.gwt.core.client.Scheduler.RepeatingCommand
    LZMA compressor.
    • Field Detail

      • DEFAULT_COMPRESSION_MODE

        public static final CompressionMode DEFAULT_COMPRESSION_MODE
        The default compression mode (3).
    • Constructor Detail

      • LZMACompressor

        public LZMACompressor​(InputStream input,
                              OutputStream output,
                              long length,
                              CompressionMode mode)
                       throws IOException
        Primary constructor.

        The given length limits how much data will be read from the input and will be encoded at the beginning of the compressed output. This allows decompressors to determine the uncompressed length without having to decompress the entire content, and causes the decompressor to stop decompressing at that point. If the length is not known, -1 should be used.

        The input and output streams will not be closed when the operation completes.

        Parameters:
        input - uncompressed input
        output - compressed output
        length - length of the input data if known, otherwise -1
        mode - compression mode
        Throws:
        IllegalArgumentException - if length is less than -1
        IllegalArgumentException - if mode is null
        IOException - if input or output does
    • Method Detail

      • execute

        public boolean execute()
        Process the next chunk of data. If an IOException is thrown during processing, this returns false and getException() will return the caught exception.
        Specified by:
        execute in interface com.google.gwt.core.client.Scheduler.RepeatingCommand
        Returns:
        true if there is more work to do, otherwise false
        Throws:
        IllegalStateException - if this compression operation has already completed
      • getProgress

        public double getProgress()
        Determine how much of the input data has been compressed so far. If a length of -1 was given to the constructor, then this always returns zero.
        Returns:
        a value from 0.0 to 1.0
      • getException

        public IOException getException()
        Get the exception thrown during the previous execution round, if any. Note: this method must be checked after compression is complete to determine if there was an error.
        Returns:
        thrown exception, or null if none was ever thrown