org.at4j.comp.lzma
Class LzmaInputStreamSettings

java.lang.Object
  extended by org.at4j.comp.lzma.LzmaInputStreamSettings

public class LzmaInputStreamSettings
extends Object

This object contains configuration that decides how a LzmaInputStream behaves. When new:ed, this object contains the default settings.

Since:
1.0
Author:
Karl Gustafsson
See Also:
LzmaInputStream

Field Summary
static int DEFAULT_MAX_DATA_QUEUE_DEPTH
          The default maximum depth of the incoming data queue.
static boolean DEFAULT_READ_UNCOMPRESSED_SIZE
          By default, the stream tries to read the uncompressed size of the data after reading the decoder properties.
 
Constructor Summary
LzmaInputStreamSettings()
           
 
Method Summary
 int getMaxDataQueueDepth()
          Get the maximum depth of the incoming data queue.
 byte[] getProperties()
          Get the decoder properties or null if they are not known beforehand.
 ThreadFactory getThreadFactory()
          Get the thread factory that will be used for creating the LZMA decompression thread.
 long getUncompressedSize()
          Get the size of uncompressed data in the stream.
 boolean isReadUncompressedSize()
          Should the uncompressed size of data in the stream be read after the stream properties header?
 LzmaInputStreamSettings setMaxDataQueueDepth(int depth)
          Set the maximum depth of the incoming data queue.
 LzmaInputStreamSettings setProperties(byte[] barr)
          Set the stream decoder properties (five bytes).
 LzmaInputStreamSettings setReadUncompressedSize(boolean b)
          Should the size of the data in the stream when uncompressed be read after the encoding settings header has been read? If the uncompressed size can be determined in some other way, this may be omitted from the stream.
 LzmaInputStreamSettings setThreadFactory(ThreadFactory tf)
          Set the thread factory to use for creating the thread that will run the LZMA decompression.
 LzmaInputStreamSettings setUncompressedSize(long size)
          Set the uncompressed size of the data that can be read from the stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_READ_UNCOMPRESSED_SIZE

public static final boolean DEFAULT_READ_UNCOMPRESSED_SIZE
By default, the stream tries to read the uncompressed size of the data after reading the decoder properties. See setReadUncompressedSize(boolean).

See Also:
Constant Field Values

DEFAULT_MAX_DATA_QUEUE_DEPTH

public static final int DEFAULT_MAX_DATA_QUEUE_DEPTH
The default maximum depth of the incoming data queue. See setMaxDataQueueDepth(int).

See Also:
Constant Field Values
Constructor Detail

LzmaInputStreamSettings

public LzmaInputStreamSettings()
Method Detail

setReadUncompressedSize

public LzmaInputStreamSettings setReadUncompressedSize(boolean b)
Should the size of the data in the stream when uncompressed be read after the encoding settings header has been read? If the uncompressed size can be determined in some other way, this may be omitted from the stream.

The default behavior is to read the data size.

Even if the uncompressed data size is set with setUncompressedSize(long), the input stream will try to read the size anyway if this is set to true. In this case, the read size is discarded and the size from setUncompressedSize(long) is used.

Parameters:
b - Should the data size be read?
Returns:
this
See Also:
setUncompressedSize(long)

isReadUncompressedSize

public boolean isReadUncompressedSize()
Should the uncompressed size of data in the stream be read after the stream properties header?

Returns:
true if the uncompressed size of data in the stream is read after the stream properties header.
See Also:
setReadUncompressedSize(boolean)

setUncompressedSize

public LzmaInputStreamSettings setUncompressedSize(long size)
                                            throws IllegalArgumentException
Set the uncompressed size of the data that can be read from the stream. By default, this is set to -1 (unknown).

Parameters:
size - The size of uncompressed data in the stream.
Returns:
this.
Throws:
IllegalArgumentException - If the size is less than -1.
See Also:
setReadUncompressedSize(boolean)

getUncompressedSize

public long getUncompressedSize()
Get the size of uncompressed data in the stream.

Returns:
The size of uncompressed data in the stream, or -1 if that is not known beforehand.
See Also:
setUncompressedSize(long)

setProperties

public LzmaInputStreamSettings setProperties(byte[] barr)
                                      throws IllegalArgumentException
Set the stream decoder properties (five bytes). By default, the input stream tries to read the decoder properties from the head of the stream (the first five bytes). If this property is set, it does not, and uses the properties set here instead.

Parameters:
barr - The decoder properties.
Returns:
this
Throws:
IllegalArgumentException - If the property array is not five bytes long.

getProperties

public byte[] getProperties()
Get the decoder properties or null if they are not known beforehand.

Returns:
The decoder properties.
See Also:
setProperties(byte[])

setMaxDataQueueDepth

public LzmaInputStreamSettings setMaxDataQueueDepth(int depth)
                                             throws IllegalArgumentException
Set the maximum depth of the incoming data queue. The incoming data queue holds data that the LZMA decoder has decoded before it is read from the input stream. Each entry in the queue is about the size of the decoder's dictionary (large), so it makes sense to keep the maximum depth low.

The default value of this is 1. Setting it to 2 may give a slightly faster decompression at the expense of a higher memory usage.

Parameters:
depth - The maximum depth of the incoming data queue.
Returns:
this
Throws:
IllegalArgumentException - If the depth is less than 1.

getMaxDataQueueDepth

public int getMaxDataQueueDepth()
Get the maximum depth of the incoming data queue.

Returns:
The maximum depth of the incoming data queue.
See Also:
setMaxDataQueueDepth(int)

setThreadFactory

public LzmaInputStreamSettings setThreadFactory(ThreadFactory tf)
Set the thread factory to use for creating the thread that will run the LZMA decompression.

If this is not set, the LzmaInputStream will just create a thread with new Thread.

By default, this property is null.

Parameters:
tf - The thread factory, or null if the LzmaInputStream should use new Thread to create the decompression thread.
Returns:
this

getThreadFactory

public ThreadFactory getThreadFactory()
Get the thread factory that will be used for creating the LZMA decompression thread.

Returns:
The thread factory, or null if not set.