com.limegroup.gnutella
Class IncompleteFileDesc

java.lang.Object
  extended bycom.limegroup.gnutella.FileDesc
      extended bycom.limegroup.gnutella.IncompleteFileDesc
All Implemented Interfaces:
AlternateLocationCollector, HTTPHeaderValue

public class IncompleteFileDesc
extends FileDesc
implements HTTPHeaderValue

This class extends FileDesc and wraps an incomplete File, so it can be used for partial file sharing.


Constructor Summary
IncompleteFileDesc(java.io.File file, java.util.Set urns, int index, java.lang.String completedName, int completedSize, VerifyingFile vf)
          Constructor for the IncompleteFileDesc object.
 
Method Summary
 boolean add(AlternateLocation al)
          Adds the alternate location to this FileDesc and also notifies the ManagedDownloader of a new location for this.
 int addAll(AlternateLocationCollection alc)
          Adds the alternate locations to this FileDesc and also notifies the ManagedDownloader of new locations for this.
 boolean addVerified(AlternateLocation al)
          Adds a verified location to this FileDesc, not notifying the ManagedDownloader of the location.
 java.io.InputStream createInputStream()
          Opens an input stream to the File instance for this FileDesc.
 java.lang.String getAvailableRanges()
          Returns the available ranges as an HTTP string value.
 java.lang.String getName()
          Returns the completed name of this file.
 long getSize()
          Returns the completed size of the file on disk, in bytes.
 java.lang.String httpStringValue()
          Returns a string representation of the HTTP header value for this class.
 boolean isRangeSatisfiable(Interval range)
          Determines whether or not the given interval is within the range of our incomplete file.
 boolean isRangeSatisfiable(int low, int high)
          Determines whether or not the given range is satisfied by this incomplete file.
 java.lang.String toString()
           
 
Methods inherited from class com.limegroup.gnutella.FileDesc
addLimeXMLDocument, addUrnsForSelf, calculateAndCacheURN, containsUrn, getAlternateLocationCollection, getAltLocsSize, getAttemptedUploads, getCompletedUploads, getFile, getHitCount, getIndex, getLimeXMLDocuments, getPath, getSHA1Urn, getUrns, hasAlternateLocations, hasUrns, incrementAttemptedUploads, incrementCompletedUploads, incrementHitCount, lastModified, remove, removeLimeXMLDocument, replaceLimeXMLDocument
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IncompleteFileDesc

public IncompleteFileDesc(java.io.File file,
                          java.util.Set urns,
                          int index,
                          java.lang.String completedName,
                          int completedSize,
                          VerifyingFile vf)
Constructor for the IncompleteFileDesc object.

Method Detail

getSize

public long getSize()
Returns the completed size of the file on disk, in bytes.

Overrides:
getSize in class FileDesc
Returns:
the size of the file on disk, in bytes

getName

public java.lang.String getName()
Returns the completed name of this file.

Overrides:
getName in class FileDesc
Returns:
the name of this file

createInputStream

public java.io.InputStream createInputStream()
                                      throws java.io.FileNotFoundException
Opens an input stream to the File instance for this FileDesc.

Overrides:
createInputStream in class FileDesc
Returns:
an InputStream to the File instance
Throws:
FileNotFoundException - if the file represented by the File instance could not be found
java.io.FileNotFoundException

add

public boolean add(AlternateLocation al)
Adds the alternate location to this FileDesc and also notifies the ManagedDownloader of a new location for this.

Specified by:
add in interface AlternateLocationCollector
Overrides:
add in class FileDesc

addVerified

public boolean addVerified(AlternateLocation al)
Adds a verified location to this FileDesc, not notifying the ManagedDownloader of the location.


addAll

public int addAll(AlternateLocationCollection alc)
Adds the alternate locations to this FileDesc and also notifies the ManagedDownloader of new locations for this.

Specified by:
addAll in interface AlternateLocationCollector
Overrides:
addAll in class FileDesc
Parameters:
alc - the AlternateLocationCollection to add

getAvailableRanges

public java.lang.String getAvailableRanges()
Returns the available ranges as an HTTP string value.


isRangeSatisfiable

public boolean isRangeSatisfiable(int low,
                                  int high)
Determines whether or not the given range is satisfied by this incomplete file.


isRangeSatisfiable

public boolean isRangeSatisfiable(Interval range)
Determines whether or not the given interval is within the range of our incomplete file.


httpStringValue

public java.lang.String httpStringValue()
Description copied from interface: HTTPHeaderValue
Returns a string representation of the HTTP header value for this class.

Specified by:
httpStringValue in interface HTTPHeaderValue
Returns:
a string representation of the HTTP header value for this class

toString

public java.lang.String toString()
Overrides:
toString in class FileDesc