Class HuffmanCode

java.lang.Object
  extended by HuffmanCode

public class HuffmanCode
extends java.lang.Object

Driver to create Huffman codes and encoded strings.


Constructor Summary
HuffmanCode(java.lang.String initialString)
          Establish this Huffman code based on an initial string.
 
Method Summary
 java.lang.String decode(java.lang.String encoded)
          Decode a string using this Huffman code.
 java.lang.String encode(java.lang.String cleartext)
          Encode a string using this Huffman code.
 java.util.Map<java.lang.Character,java.lang.String> getCodeMap()
          Retrieve the internal Huffman Code Map.
 HNode getCodeTree()
          Retrieve the internal Huffman Code Tree.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HuffmanCode

public HuffmanCode(java.lang.String initialString)
Establish this Huffman code based on an initial string.

Parameters:
initialString - the initial string used to create the code
Method Detail

encode

public java.lang.String encode(java.lang.String cleartext)
Encode a string using this Huffman code.

Parameters:
cleartext - the string to encode
Returns:
the encoded string

decode

public java.lang.String decode(java.lang.String encoded)
Decode a string using this Huffman code.

Parameters:
encoded - the string to decode
Returns:
the decoded string

getCodeMap

public java.util.Map<java.lang.Character,java.lang.String> getCodeMap()
Retrieve the internal Huffman Code Map.

Returns:
the code map for this Huffman Code

getCodeTree

public HNode getCodeTree()
Retrieve the internal Huffman Code Tree.

Returns:
the code tree for this Huffman Code