com.limegroup.gnutella.downloader
Class VerifyingFile

java.lang.Object
  extended bycom.limegroup.gnutella.downloader.VerifyingFile

public class VerifyingFile
extends java.lang.Object

All the HTTPDownloaders associated with a ManagedDownloader will commit the parts of the file they are downloading through a single object of this class.

Keeps track of which bytes have already been written to disk, and based on this information makes a decision about whether or not to do checking.

Users of this class must call open(...) before calling writeBlock.


Constructor Summary
VerifyingFile(boolean checkOverlap)
           
 
Method Summary
 void addInterval(Interval interval)
          used to add blocks direcly.
 void clearManagedDownloader()
          Clears the ManagedDownloader variable, allowing it to be GC'ed.
 void close()
          Closes the file output stream.
 java.util.Iterator getBlocks()
           
 java.util.List getBlocksAsList()
           
 int getBlockSize()
           
 java.util.Iterator getFreeBlocks(int maxSize)
           
 ManagedDownloader getManagedDownloader()
          Returns the ManagedDownloader this VerifyingFile is associated with.
 boolean isCorrupted()
          Returns whether or not we have determined if the written is corrupted.
 void open(java.io.File file, ManagedDownloader md)
           
 void writeBlock(long currPos, int numBytes, byte[] buf)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VerifyingFile

public VerifyingFile(boolean checkOverlap)
Method Detail

open

public void open(java.io.File file,
                 ManagedDownloader md)
          throws java.io.IOException
Throws:
java.io.IOException

addInterval

public void addInterval(Interval interval)
used to add blocks direcly. WARNING: the intervals added using this method are not checked for overlaps, incorrect use of this method, may break integrity constrains.


writeBlock

public void writeBlock(long currPos,
                       int numBytes,
                       byte[] buf)
                throws java.io.IOException
Throws:
java.io.IOException

getBlocks

public java.util.Iterator getBlocks()

getBlocksAsList

public java.util.List getBlocksAsList()

getFreeBlocks

public java.util.Iterator getFreeBlocks(int maxSize)

getBlockSize

public int getBlockSize()

close

public void close()
Closes the file output stream.


clearManagedDownloader

public void clearManagedDownloader()
Clears the ManagedDownloader variable, allowing it to be GC'ed.


isCorrupted

public boolean isCorrupted()
Returns whether or not we have determined if the written is corrupted.


getManagedDownloader

public ManagedDownloader getManagedDownloader()
Returns the ManagedDownloader this VerifyingFile is associated with. If this VerifyingFile is closed, the return value will be null.