assignment4
Class SimpleHuffProcessor
java.lang.Object
assignment4.SimpleHuffProcessor
- All Implemented Interfaces:
- IHuffConstants, IHuffProcessor
public class SimpleHuffProcessor
- extends java.lang.Object
- implements IHuffProcessor
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. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SimpleHuffProcessor
public SimpleHuffProcessor()
compress
public int compress(java.io.InputStream in,
java.io.OutputStream out,
boolean force)
throws java.io.IOException
- Description copied from interface:
IHuffProcessor
- Compresses input to output, where the same InputStream has
previously been pre-processed via
preprocessCompress
storing state used by this call.
- Specified by:
compress
in interface IHuffProcessor
- 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
preprocessCompress
public int preprocessCompress(java.io.InputStream in)
throws java.io.IOException
- Description copied from interface:
IHuffProcessor
- 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.
- Specified by:
preprocessCompress
in interface IHuffProcessor
- Parameters:
in
- is the stream which could be subsequently compressed
- Returns:
- number of bits saved by compression
- Throws:
java.io.IOException
uncompress
public int uncompress(java.io.InputStream in,
java.io.OutputStream out)
throws java.io.IOException
- Description copied from interface:
IHuffProcessor
- Uncompress a previously compressed stream in, writing the
uncompressed bits/data to out.
- Specified by:
uncompress
in interface IHuffProcessor
- 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
setViewer
public void setViewer(HuffViewer viewer)
- Description copied from interface:
IHuffProcessor
- Make sure this model communicates with some view.
- Specified by:
setViewer
in interface IHuffProcessor
- Parameters:
viewer
- is the view for communicating.