assignment4
Interface IHuffProcessor

All Superinterfaces:
IHuffConstants
All Known Implementing Classes:
SimpleHuffProcessor

public interface IHuffProcessor
extends IHuffConstants


Field Summary
 
Fields inherited from interface assignment4.IHuffConstants
ALPH_SIZE, BITS_PER_INT, BITS_PER_WORD, MAGIC_NUMBER, PSEUDO_EOF, STORE_COUNTS, STORE_CUSTOM, STORE_TREE
 
Method Summary
 int compress(java.io.InputStream in, java.io.OutputStream out, boolean force)
          Compresses input to output, where the same InputStream has previously been pre-processed via preprocessCompress storing state used by this call.
 int preprocessCompress(java.io.InputStream in)
          Preprocess data so that compression is possible --- count characters/create tree/store state so that a subsequent call to compress will work.
 void setViewer(HuffViewer viewer)
          Make sure this model communicates with some view.
 int uncompress(java.io.InputStream in, java.io.OutputStream out)
          Uncompress a previously compressed stream in, writing the uncompressed bits/data to out.
 

Method Detail

setViewer

void setViewer(HuffViewer viewer)
Make sure this model communicates with some view.

Parameters:
viewer - is the view for communicating.

preprocessCompress

int preprocessCompress(java.io.InputStream in)
                       throws java.io.IOException
Preprocess data so that compression is possible --- count characters/create tree/store state so that a subsequent call to compress will work. The InputStream is not a BitInputStream, so wrap it into one as needed.

Parameters:
in - is the stream which could be subsequently compressed
Returns:
number of bits saved by compression
Throws:
java.io.IOException

compress

int compress(java.io.InputStream in,
             java.io.OutputStream out,
             boolean force)
             throws java.io.IOException
Compresses input to output, where the same InputStream has previously been pre-processed via preprocessCompress storing state used by this call.

Parameters:
in - is the stream being compressed (not a BitInputStream)
out - is bound to a file/stream to which bits are written for the compressed file (not a BitOutputStream)
Returns:
the number of bits written
Throws:
java.io.IOException

uncompress

int uncompress(java.io.InputStream in,
               java.io.OutputStream out)
               throws java.io.IOException
Uncompress a previously compressed stream in, writing the uncompressed bits/data to out.

Parameters:
in - is the previously compressed data (not a BitInputStream)
out - is the uncompressed file/stream
Returns:
the number of bits written to the uncompressed file/stream
Throws:
java.io.IOException