|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.coyotegulch.jisp.Huffman
Compresses and decompresses objects using the Huffman algorithm. Huffman encoding creates a set of codes for which the shortest code represents the most common piece of data. Codes created by the Huffman algorithm require a file to be analyzed, counting bytes to determine their frequency. From the frequencies, the Huffman algorithm builds a table of codes used to compress the information. Including the table of codes with the compressed data allows the original file to be reconstructed.
To be most effective, Huffman encoding uses a variable length code, where no code is a prefix of another, which makes decompression easier by allowing the extraction of the file bit-by-bit. The shortest codes are assigned to the most common characters, with infrequent characters receiving longer codes.
Objects to be compressed must be Serializable.
HuffmanEncoded
Constructor Summary | |
Huffman()
|
Method Summary | |
static java.lang.Object |
decode(HuffmanEncoded enc)
Decodes a compressed object using the Huffman algorithm. |
static HuffmanEncoded |
encode(java.lang.Object obj)
Encodes an object using Huffman compression. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Huffman()
Method Detail |
public static HuffmanEncoded encode(java.lang.Object obj) throws java.io.IOException
obj
- serializable object to be compressed
HuffmanEncoded
object containing the compressed
object and its encoding table
java.io.IOException
- when an I/O exception is thrown by an underlying java.io.* classHuffmanEncoded
public static java.lang.Object decode(HuffmanEncoded enc) throws java.io.IOException, java.lang.ClassNotFoundException
enc
- object to be decompressed
Object
java.io.IOException
- when an I/O exception is thrown by an underlying java.io.* class
java.lang.ClassNotFoundException
- when an explicit cast failsHuffmanEncoded
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |