org.egothor.duplicity.util
Class Hasher

java.lang.Object
  extended by org.egothor.duplicity.util.Hasher
All Implemented Interfaces:
UIDProducer

public class Hasher
extends java.lang.Object
implements UIDProducer

Simple implementation of interface UIDProducer. The UIDs are produced by hash function. The implementation is not perfect, in the sense that the provided mapping from tokens to UIDs is not surjective nor it does avoid collisions. For the collisions let's say that as we do not know the whole set of possible tokens, construction of perfect hash function is not possible. For the non-surjectivity of the mapping, I believe it is not a problem. Currently there are implementations of DJB and SDBM algorithms. The type of algorithm to be used must be declared on creating of the object of this class.

Author:
Kate�ina Dufkov�

Field Summary
static int DEFAULT
          Constant for default hash algorith.
static int DJB
          Constant for DJB hash algorith.
static int SDBM
          Constant for SDBM hash algorith.
 
Constructor Summary
Hasher(int type)
          Constructor sets the type of hash function to be used.
 
Method Summary
 int getType()
           
 long getUID(java.lang.String str)
          Get the UID for given String value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DJB

public static final int DJB
Constant for DJB hash algorith.

See Also:
Constant Field Values

SDBM

public static final int SDBM
Constant for SDBM hash algorith.

See Also:
Constant Field Values

DEFAULT

public static final int DEFAULT
Constant for default hash algorith.

See Also:
Constant Field Values
Constructor Detail

Hasher

public Hasher(int type)
Constructor sets the type of hash function to be used.

Parameters:
type - constant of the class Hasher
Method Detail

getType

public int getType()

getUID

public long getUID(java.lang.String str)
Get the UID for given String value.

Specified by:
getUID in interface UIDProducer
Parameters:
str -
Returns:
UID