|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.limegroup.gnutella.FileDesc
This class contains data for an individual shared file. It also provides various utility methods for checking against the encapsulated data.
Constructing a FileDesc is usually done in two steps, which allows the caller to avoid holding a lock when hashing a file:
Set urns=FileDesc.calculateAndCacheURN(file); FileDesc fd=new FileDesc(file, urns, index);
Constructor Summary | |
FileDesc(java.io.File file,
java.util.Set urns,
int index)
Constructs a new FileDesc instance from the specified File class and the associated urns. |
Method Summary | |
boolean |
add(AlternateLocation al)
Implements AlternateLocationCollector interface. |
int |
addAll(AlternateLocationCollection alc)
Implements the AlternateLocationCollector interface. |
void |
addLimeXMLDocument(LimeXMLDocument doc)
Adds a LimeXMLDocument to this FileDesc. |
void |
addUrnsForSelf()
Adds URNs for this' location to the alternate location collection. |
static java.util.Set |
calculateAndCacheURN(java.io.File file)
Returns the set of URNs for a file to be passed to the FileDesc constructor. |
boolean |
containsUrn(URN urn)
Determine whether or not the given URN instance is contained in this FileDesc. |
java.io.InputStream |
createInputStream()
Opens an input stream to the File instance for this FileDesc. |
AlternateLocationCollection |
getAlternateLocationCollection()
|
int |
getAltLocsSize()
Number of alternate locations this collector is holding |
int |
getAttemptedUploads()
|
int |
getCompletedUploads()
|
java.io.File |
getFile()
Returns the File instance for this FileDesc. |
int |
getHitCount()
|
int |
getIndex()
Returns the index of this file in our file data structure. |
java.util.List |
getLimeXMLDocuments()
Returns the LimeXMLDocuments for this FileDesc. |
java.lang.String |
getName()
Returns the name of this file. |
java.lang.String |
getPath()
Returns the absolute path of the file represented wrapped by this FileDesc. |
URN |
getSHA1Urn()
Accessor for the SHA1 URN instance for this collection. |
long |
getSize()
Returns the size of the file on disk, in bytes. |
java.util.Set |
getUrns()
Returns a new Set instance containing the URNs for the this FileDesc. |
boolean |
hasAlternateLocations()
Returns whether or not this AlternateLocationCollector has any alternate locations. |
boolean |
hasUrns()
Returns whether or not this FileDesc has any urns. |
int |
incrementAttemptedUploads()
Increase & return the new attempted uploads |
int |
incrementCompletedUploads()
Increase & return the new completed uploads |
int |
incrementHitCount()
Increase & return the new hit count. |
long |
lastModified()
Returns the last modification time for the file according to this FileDesc instance. |
boolean |
remove(AlternateLocation al)
Removes the specified location from this collection. |
boolean |
removeLimeXMLDocument(LimeXMLDocument toRemove)
Removes a LimeXMLDocument from the FileDesc. |
boolean |
replaceLimeXMLDocument(LimeXMLDocument oldDoc,
LimeXMLDocument newDoc)
Replaces one LimeXMLDocument with another. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public FileDesc(java.io.File file, java.util.Set urns, int index)
file
- the File instance to use for constructing the
FileDescurns
- the return value from calculateAndCacheURN(file);
an unmodifiable Set of URN's.index
- the index in the FileManagercalculateAndCacheURN
Method Detail |
public static java.util.Set calculateAndCacheURN(java.io.File file) throws java.io.IOException, java.lang.InterruptedException
NullPointerException
- if the file argument is
null
IllegalArgumentException
- if the file argument
denotes a file that is not a file on disk
IOException
- if there is an IO error calculating the
URN
InterruptedException
- if the thread that calculates
the URN is interrupted
java.io.IOException
java.lang.InterruptedException
public boolean hasUrns()
public int getIndex()
public long getSize()
public java.lang.String getName()
public long lastModified()
public URN getSHA1Urn()
AlternateLocationCollector
getSHA1Urn
in interface AlternateLocationCollector
public java.io.File getFile()
public java.util.Set getUrns()
public java.lang.String getPath()
public void addLimeXMLDocument(LimeXMLDocument doc)
public boolean replaceLimeXMLDocument(LimeXMLDocument oldDoc, LimeXMLDocument newDoc)
public boolean removeLimeXMLDocument(LimeXMLDocument toRemove)
public java.util.List getLimeXMLDocuments()
public AlternateLocationCollection getAlternateLocationCollection()
public void addUrnsForSelf()
public boolean add(AlternateLocation al)
add
in interface AlternateLocationCollector
NullPointerException
- if the argument is null
IllegalArgumentException
- if the alternate location
has a different SHA1 than this file, or if its sha1 is nullpublic boolean remove(AlternateLocation al)
AlternateLocationCollector
remove
in interface AlternateLocationCollector
NullPointerException
- if the argument is null
IllegalArgumentException
- if the alternate location
has a different SHA1 than this file, or if its sha1 is nullpublic int addAll(AlternateLocationCollection alc)
addAll
in interface AlternateLocationCollector
alc
- the AlternateLocationCollection to add
NullPointerException
- if alc is
null
IllegalArgumentException
- if the SHA1 of the
collection to add does not match the collection of thispublic boolean hasAlternateLocations()
AlternateLocationCollector
hasAlternateLocations
in interface AlternateLocationCollector
public int getAltLocsSize()
AlternateLocationCollector
getAltLocsSize
in interface AlternateLocationCollector
public boolean containsUrn(URN urn)
urn
- the URN instance to check for
public int incrementHitCount()
public int getHitCount()
public int incrementAttemptedUploads()
public int getAttemptedUploads()
public int incrementCompletedUploads()
public int getCompletedUploads()
public java.io.InputStream createInputStream() throws java.io.FileNotFoundException
FileNotFoundException
- if the file represented
by the File instance could not be found
java.io.FileNotFoundException
public java.lang.String toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |