org.biffle.cliff.pearl
Class Util

java.lang.Object
  |
  +--org.biffle.cliff.pearl.Util

public abstract class Util
extends java.lang.Object

Utility functions -- anything I found myself repeating over and over.


Method Summary
static int getLEInt(byte[] src, int offset)
          Converts four bytes from an array (representing a little-endian integer) into an int.
static long getLELong(byte[] src, int offset)
          Converts eight bytes from an array (representing a little-endian long) into a long.
static void putLEInt(int value, byte[] target, int offset)
          Writes an int into a byte array as a little-endian integer.
static void putLELong(long value, byte[] target, int offset)
          Writes a long into a byte array as a little-endian long.
static java.lang.String ridOfFile(java.io.RandomAccessFile f)
          Computes the RID (a sort of quick hash) of a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getLEInt

public static int getLEInt(byte[] src,
                           int offset)
Converts four bytes from an array (representing a little-endian integer) into an int.


putLEInt

public static void putLEInt(int value,
                            byte[] target,
                            int offset)
Writes an int into a byte array as a little-endian integer.


getLELong

public static long getLELong(byte[] src,
                             int offset)
Converts eight bytes from an array (representing a little-endian long) into a long.


putLELong

public static void putLELong(long value,
                             byte[] target,
                             int offset)
Writes a long into a byte array as a little-endian long.


ridOfFile

public static java.lang.String ridOfFile(java.io.RandomAccessFile f)
                                  throws java.io.IOException
Computes the RID (a sort of quick hash) of a file. The RID algorithm works according to the following pseudocode:
 if(length of file <= 64k) {
 	return MD5(file);
 } else {
 	A = MD5(first 64k);
 	B = MD5(last 64k);
 	C = MD5(64k starting at (length - 64k)/2);
 	return A ^ B ^ C;
 }
 
This is probably designed to be an optimization for large files; it's used by the Karma (and apparently the Empeg before it) to hash music files.

java.io.IOException