MAM API
(developer's version)

Class MAMUtil

java.lang.Object
  extended by MAMUtil

public final class MAMUtil
extends Object

Miscellaneous utilities for MAMCodec.


Constructor Summary
private MAMUtil()
          No instantiation for the library class
 
Method Summary
static void callCodec(Codec codec, InputStream in, OutputStream out)
           
static String callCodec(Codec codec, String input)
          String coding function that can be used for test purposes.
static byte[] getDefaultByteOrder()
          Defaults for move-to-front transformation.
static byte[] read(InputStream in)
           
static int read(InputStream in, byte[] buffer)
          Read as much as possible until the end of stream.
static int readInt(InputStream in)
           
static byte[] setChars()
           
static int[] setDefaultDistribution()
           
static int setFrequencyDistribution(int[] dist, int[] freqs)
           
static int[] setInitialCounts(int[] freq, int[] symbols)
          The function must be called before the encoding.
static byte[] toBinaryBytes(byte bits)
          Converts one byte to a sequence of eight bytes of zeros and ones corresponding the bit sequence.
static byte[] toBytes(int number)
          Converts a 32 bit int into a array of four bytes.
static int toInt(byte[] b)
          Converts four bytes to a 32 bit int.
static int toInt(byte[] b, int offset)
          Converts four bytes to a 32 bit int.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MAMUtil

private MAMUtil()
No instantiation for the library class

Method Detail

setDefaultDistribution

public static int[] setDefaultDistribution()

setChars

public static byte[] setChars()

getDefaultByteOrder

public static byte[] getDefaultByteOrder()
Defaults for move-to-front transformation.


setFrequencyDistribution

public static int setFrequencyDistribution(int[] dist,
                                           int[] freqs)

callCodec

public static String callCodec(Codec codec,
                               String input)
String coding function that can be used for test purposes. Character encodings may lead to misinterpretations of the results.


callCodec

public static void callCodec(Codec codec,
                             InputStream in,
                             OutputStream out)

read

public static int read(InputStream in,
                       byte[] buffer)
                throws IOException
Read as much as possible until the end of stream. This method may block and wait for further input.

Throws:
IOException

read

public static byte[] read(InputStream in)
                   throws IOException
Throws:
IOException

readInt

public static int readInt(InputStream in)
                   throws IOException
Throws:
IOException

toBytes

public static byte[] toBytes(int number)
Converts a 32 bit int into a array of four bytes.


toInt

public static int toInt(byte[] b)
Converts four bytes to a 32 bit int.


toInt

public static int toInt(byte[] b,
                        int offset)
Converts four bytes to a 32 bit int. The bytes are read starting from the given position.


toBinaryBytes

public static byte[] toBinaryBytes(byte bits)
Converts one byte to a sequence of eight bytes of zeros and ones corresponding the bit sequence.


setInitialCounts

public static int[] setInitialCounts(int[] freq,
                                     int[] symbols)
The function must be called before the encoding. Following should hold: freq.length == symbols.length. Symbols which no probability have count 0. The sum of freq should not be over Integer.MAX_VALUE - 1


MAM API
(developer's version)

Copyright © 2007 Aija Niissalo, Marko Laakso, Markus Heinonen.