sam.io
Class HuffmanMixer

java.lang.Object
  |
  +--sam.io.Mixer
        |
        +--sam.io.HuffmanMixer

public class HuffmanMixer
extends Mixer

Implementation of a mixer that is well-suited for Huffman-encoded streams It inserts pseudo-randomized characters drawn in a way that is equivalent to draw an arbitrary Huffman tree among all possible ones. Beware of confusions with the sam.io.Huffman class !


Nested Class Summary
 
Nested classes inherited from class sam.io.Mixer
Mixer.InputStream, Mixer.OutputStream
 
Field Summary
 
Fields inherited from class sam.io.Mixer
DUMMY
 
Constructor Summary
HuffmanMixer(sam.io.Huffman huffman)
           
 
Method Summary
protected  long getDataChunkLength(long blockSize)
          Sets the next data chunk length, in bytes.
 void readGarbageChunk(java.io.InputStream stream, long length)
          Reads garbage data from the stream.
 java.lang.String verbose()
           
 void writeGarbageChunk(java.io.OutputStream delegee)
          Writes garbage data to the stream.
 
Methods inherited from class sam.io.Mixer
blockSize, getTrace, nextDataChunkLength, setBlockSize, setTrace, setTracker
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HuffmanMixer

public HuffmanMixer(sam.io.Huffman huffman)
Method Detail

verbose

public java.lang.String verbose()

getDataChunkLength

protected long getDataChunkLength(long blockSize)
Description copied from class: Mixer
Sets the next data chunk length, in bytes.

Specified by:
getDataChunkLength in class Mixer
Parameters:
blockSize - the block size of the data stream, which might be zero to specify infinite block size A lazy implementation might just return blockSize
Returns:
desired data chunk length, or zero to specify unlimited data chunk

writeGarbageChunk

public void writeGarbageChunk(java.io.OutputStream delegee)
                       throws java.io.IOException
Description copied from class: Mixer
Writes garbage data to the stream.

Specified by:
writeGarbageChunk in class Mixer
Parameters:
delegee - the output to write onto Note that the number of bytes written will be kept back automatically
java.io.IOException

readGarbageChunk

public void readGarbageChunk(java.io.InputStream stream,
                             long length)
                      throws java.io.IOException
Description copied from class: Mixer
Reads garbage data from the stream.

Specified by:
readGarbageChunk in class Mixer
Parameters:
stream - the input to write onto
length - the number of garbage bytes to read
java.io.IOException