Package org.dellroad.lzma.client
Class LZMACompressor
- java.lang.Object
-
- org.dellroad.lzma.client.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 Summary
Fields Modifier and Type Field Description static CompressionModeDEFAULT_COMPRESSION_MODEThe default compression mode (3).
-
Constructor Summary
Constructors Constructor Description LZMACompressor(InputStream input, OutputStream output)Construct an encoder with unknown input length and using thedefault compression mode.LZMACompressor(InputStream input, OutputStream output, long length)Construct an encoder with unknown using thedefault compression mode.LZMACompressor(InputStream input, OutputStream output, long length, CompressionMode mode)Primary constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanexecute()Process the next chunk of data.IOExceptiongetException()Get the exception thrown during the previous execution round, if any.doublegetProgress()Determine how much of the input data has been compressed so far.
-
-
-
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) throws IOException
Construct an encoder with unknown input length and using thedefault compression mode.This is a convenience constructor, equivalent to:
LZMACompressor(input, output, -1, DEFAULT_COMPRESSION_MODE)- Throws:
IOException
-
LZMACompressor
public LZMACompressor(InputStream input, OutputStream output, long length) throws IOException
Construct an encoder with unknown using thedefault compression mode.This is a convenience constructor, equivalent to:
LZMACompressor(input, output, length, DEFAULT_COMPRESSION_MODE)- Throws:
IOException
-
LZMACompressor
public LZMACompressor(InputStream input, OutputStream output, long length, CompressionMode mode) throws IOException
Primary constructor.The given
lengthlimits 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,-1should be used.The input and output streams will not be closed when the operation completes.
- Parameters:
input- uncompressed inputoutput- compressed outputlength- length of the input data if known, otherwise-1mode- compression mode- Throws:
IllegalArgumentException- iflengthis less than-1IllegalArgumentException- ifmodeis nullIOException- ifinputoroutputdoes
-
-
Method Detail
-
execute
public boolean execute()
Process the next chunk of data. If anIOExceptionis thrown during processing, this returnsfalseandgetException()will return the caught exception.- Specified by:
executein interfacecom.google.gwt.core.client.Scheduler.RepeatingCommand- Returns:
trueif there is more work to do, otherwisefalse- 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-1was 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
nullif none was ever thrown
-
-