ants.p2p.utils.donkey
Class DonkeyHashFile

java.lang.Object
  extended by ants.p2p.utils.donkey.DonkeyHashFile
All Implemented Interfaces:
DonkeyPacketConstants

public class DonkeyHashFile
extends java.lang.Object
implements DonkeyPacketConstants

Creates eDonkey2000 hashes and hashsets from files.


Field Summary
static java.beans.PropertyChangeSupport propertyChangeSupport
           
 
Fields inherited from interface ants.p2p.utils.donkey.DonkeyPacketConstants
BLOCKSIZE, MET_HEADER, OP_ACCEPTUPLOADREQ, OP_CALLBACKFAIL, OP_CALLBACKHINT, OP_CALLBACKREQUEST, OP_CALLBACKREQUESTED, OP_CANCELTRANSFER, OP_EDONKEYHEADER, OP_EDONKEYPROT, OP_EMULEPROT, OP_ENDTRANSFER, OP_EXTENDEDPROT, OP_FILELISTANSWER, OP_FILELISTREQUEST, OP_FILEREQANSWER, OP_FILEREQREGRET, OP_FILEREQUEST, OP_FILESTATUS, OP_FOUNDSOURCES, OP_GETMORESEARCHRESULT, OP_GETSERVERLIST, OP_GETSOURCES, OP_GLOBCALLBACKFAIL, OP_GLOBCALLBACKREQ, OP_GLOBEXTENDEDSEARCHREQ, OP_GLOBFOUNDSOURCES, OP_GLOBGETSOURCES, OP_GLOBSEARCHREQ, OP_GLOBSEARCHRES, OP_GLOBSERVERINFO, OP_GLOBSERVERINFOREQ, OP_GLOBSERVERSTATUS, OP_GLOBSERVERSTATUSREQ, OP_HASHSETANSWER, OP_HASHSETREQUEST, OP_HELLO, OP_HELLOANSWER, OP_IDCHANGE, OP_LOGINREQUEST, OP_MESSAGE, OP_MLDONKEYPROT, OP_OFFERFILES, OP_QUEUEPOSITION, OP_REQUESTPARTS, OP_SEARCHREQUEST, OP_SEARCHRESULT, OP_SENDINGPART, OP_SERVERINFO, OP_SERVERLIST, OP_SERVERMESSAGE, OP_SERVERSTATUS, OP_SETREQFILEID, OP_STARTUPLOADREQ, OP_UPLOADEND, PARTSIZE, PORT_LISTENER, SO_EDONKEY, SO_EMULE, SO_HYBRID, SO_MLDONKEY, SO_OLDEMULE, SO_OLDMLDONKEY, SO_OVERNET
 
Constructor Summary
DonkeyHashFile()
           
 
Method Summary
static void addPropertyChangeListener(java.beans.PropertyChangeListener pcl)
           
static byte[][] digest(java.io.File file)
          Creates a edonkey2000 hashset of a filestream.
static byte[][] doHash(java.io.File file)
          Creates a edonkey2000 hashset of a file.
static boolean isValidHashset(byte[][] hashes)
           
static void removePropertyChangeListener(java.beans.PropertyChangeListener pcl)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

propertyChangeSupport

public static java.beans.PropertyChangeSupport propertyChangeSupport
Constructor Detail

DonkeyHashFile

public DonkeyHashFile()
Method Detail

addPropertyChangeListener

public static void addPropertyChangeListener(java.beans.PropertyChangeListener pcl)

removePropertyChangeListener

public static void removePropertyChangeListener(java.beans.PropertyChangeListener pcl)

doHash

public static byte[][] doHash(java.io.File file)
Creates a edonkey2000 hashset of a file. Returned DonkeyFileHashSet object: 1st edonkeyhash of file, next are partial hashes.

Parameters:
file - *complete* file to hash
Returns:
the hashes object or null if the file was not found or an IOException ocurred

digest

public static byte[][] digest(java.io.File file)
                       throws java.io.IOException
Creates a edonkey2000 hashset of a filestream. Returnes Array of byte[] with the hashes: 1st edonkeyhash of file, next are partial hashes.

Parameters:
fis - is used to get a FileChannel which is read from its intial position till its limit
Returns:
the hashes or null if an IOException ocurred
Throws:
java.io.IOException

isValidHashset

public static boolean isValidHashset(byte[][] hashes)