Class HuffmanEncoder


  • public class HuffmanEncoder
    extends java.lang.Object

    Used to encode strings Huffman encoding.

    Characters are encoded with ISO-8859-1, if any multi-byte characters or control characters are present the encoder will throw EncodingException.

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void encode​(java.nio.ByteBuffer buffer, java.lang.String s)  
      static void encodeLowerCase​(java.nio.ByteBuffer buffer, java.lang.String s)  
      static int octetsNeeded​(byte[] b)  
      static int octetsNeeded​(java.lang.String s)  
      static int octetsNeededLowerCase​(java.lang.String s)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • octetsNeeded

        public static int octetsNeeded​(java.lang.String s)
        Parameters:
        s - the string to encode.
        Returns:
        the number of octets needed to encode the string, or -1 if it cannot be encoded.
      • octetsNeeded

        public static int octetsNeeded​(byte[] b)
        Parameters:
        b - the byte array to encode.
        Returns:
        the number of octets needed to encode the bytes, or -1 if it cannot be encoded.
      • encode

        public static void encode​(java.nio.ByteBuffer buffer,
                                  java.lang.String s)
        Parameters:
        buffer - the buffer to encode into.
        s - the string to encode.
      • octetsNeededLowerCase

        public static int octetsNeededLowerCase​(java.lang.String s)
        Parameters:
        s - the string to encode in lowercase.
        Returns:
        the number of octets needed to encode the string, or -1 if it cannot be encoded.
      • encodeLowerCase

        public static void encodeLowerCase​(java.nio.ByteBuffer buffer,
                                           java.lang.String s)
        Parameters:
        buffer - the buffer to encode into in lowercase.
        s - the string to encode.