|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.ecf.protocol.bittorrent.Torrent
public class Torrent
The Torrent
class is used for hooking onto a
TorrentFile
so that pieces can be exchanged with peers.
Method Summary | |
---|---|
void |
addHashCheckListener(IHashCheckListener listener)
Adds the specified listener to the collection of listeners for this torrent if it is not already contained. |
void |
addPieceProgressListener(IPieceProgressListener listener)
Adds the specified listener to the collection of listeners for this torrent if it is not already contained. |
void |
addTorrentErrorListener(ITorrentErrorListener listener)
Adds the specified listener to the collection of listeners for this torrent if it is not already contained. |
void |
addTorrentProgressListener(ITorrentProgressListener listener)
Adds the specified listener to the collection of listeners for this torrent if it is not already contained. |
void |
addTorrentStateListener(ITorrentStateListener listener)
Adds the specified listener to the collection of listeners for this torrent if it is not already contained. |
boolean |
delete()
Removes all information pertaining to the opened torrent in addition to removing the target that has been set for downloading or seeding. |
int |
getConnectedPeers()
Retrieves the number of peers that connections have been created for thus far. |
long |
getDiscarded()
Retrieves the amount of data that has been discarded thus far. |
long |
getDownloaded()
Retrieves the amount that has been downloaded thus far since the original call to start() . |
long |
getDownSpeed()
Gets the downloading speed as calculated over a twenty second rolling average. |
int |
getPeers()
Returns the total number of peers that are attempting to download this torrent. |
long |
getRemaining()
Retreives the number of bytes that are required to complete the download. |
int |
getSeeds()
Returns the number of seeds that are currently assisting with the distribution. |
int |
getState()
Retrieves the current state in which this torrent is currently in. |
long |
getTimeRemaining()
Retrieves the time in seconds that are remaining for this download to complete. |
TorrentFile |
getTorrentFile()
Retrieves the torrent file that was used to create this torrent. |
long |
getUploaded()
Returns the number of bytes that has been uploaded to peers thus far since calling start() . |
long |
getUpSpeed()
Retrieves the uploading speed per calculations over a twenty second rolling average. |
boolean |
performHashCheck()
Performs a hash check on all pieces for this torrnet in a separate thread. |
void |
remove()
Removes all previously saved status and configuration information regarding the opened torrent. |
boolean |
removeHashCheckListener(IHashCheckListener listener)
Removes the specified listener so that it will no longer be notified of pieces have completed the hash checking process. |
boolean |
removePieceProgressListener(IPieceProgressListener listener)
Removes the specified listener so that it will no longer be notified of a piece having downloaded some additional bytes. |
boolean |
removeTorrentErrorListener(ITorrentErrorListener listener)
Removes the specified listener so that it will no longer be notified of errors. |
boolean |
removeTorrentProgressListener(ITorrentProgressListener listener)
Removes the specified listener so that it will no longer be notified when pieces has been completed. |
boolean |
removeTorrentStateListener(ITorrentStateListener listener)
Removes the specified listener so that it will no longer be notified of state updates. |
void |
setFilesToDownload(int[] downloadChoices)
Setup file download priority levels and whether a file should even be downloaded at all. |
void |
setMaxConnections(int maxConnections)
Sets the maximum number of connections that this torrent should attempt to connect to. |
void |
setMaxDownloadSpeed(long maximum)
Sets the maximum number of bytes to download per second from peers. |
void |
setMaxUploadSpeed(long maximum)
Sets the maximum number of bytes to upload per second to peers. |
void |
start()
Contacts the tracker to begin exchanging pieces with any peers that are found. |
void |
stop()
Stops downloading, seeding, or the hash checking process for this torrent. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public void start() throws java.io.IOException
java.io.IOException
- If an error occurs while querying the tracker or connecting
to one of the provided peerspublic void stop() throws java.io.IOException
java.io.IOException
- If an IOException occurred while informing the tracker that
the client is stoppingpublic void remove()
stop()
prior to the
deletion of the files.
public boolean delete()
true
if the target file or directory has been
deleted successfully, false
otherwisepublic boolean performHashCheck()
true
if the torrent will begin performing hash
check on its pieces on a separate thread or is already running a
hash check, false if the torrent is currently
performing other operations and is unable to run a hash checkpublic void addTorrentStateListener(ITorrentStateListener listener) throws java.lang.IllegalArgumentException
getState()
.
listener
- the listener to notify
java.lang.IllegalArgumentException
- If listener
is null
public void addTorrentProgressListener(ITorrentProgressListener listener) throws java.lang.IllegalArgumentException
listener
- the listener to notify
java.lang.IllegalArgumentException
- If listener
is null
public void addPieceProgressListener(IPieceProgressListener listener) throws java.lang.IllegalArgumentException
listener
- the listener to notify
java.lang.IllegalArgumentException
- If listener
is null
public void addHashCheckListener(IHashCheckListener listener)
listener
- the listener to notify
java.lang.IllegalArgumentException
- If listener
is null
public void addTorrentErrorListener(ITorrentErrorListener listener) throws java.lang.IllegalArgumentException
listener
- the listener to notify
java.lang.IllegalArgumentException
- If listener
is null
public boolean removeTorrentStateListener(ITorrentStateListener listener)
listener
- the listener to remove
true
if one such listener was removed,
false
otherwisepublic boolean removeTorrentProgressListener(ITorrentProgressListener listener)
listener
- the listener to remove
true
if one such listener was removed,
false
otherwisepublic boolean removePieceProgressListener(IPieceProgressListener listener)
listener
- the listener to remove
true
if one such listener was removed,
false
otherwisepublic boolean removeHashCheckListener(IHashCheckListener listener)
listener
- the listener to remove
true
if one such listener was removed,
false
otherwisepublic boolean removeTorrentErrorListener(ITorrentErrorListener listener)
listener
- the listener to remove
true
if one such listener was removed,
false
otherwisepublic void setMaxConnections(int maxConnections) throws java.lang.IllegalArgumentException
maxConnections
- the maximum number of connections that should be used
java.lang.IllegalArgumentException
- If maxConnections
is negativepublic void setFilesToDownload(int[] downloadChoices)
downloadChoices
- an integer array which stores a value greater than zero if the
file should have a high priority, a value equal to zero if it
should have a regular priority, or less than zero if it should
not be downloaded at all, the values should correspond to the
files returned from TorrentFile
's
TorrentFile.getFilenames()
method
java.lang.IllegalArgumentException
- If downloadChoices
is null
or
if the length of the array is not equal to the number of
files for this torrentpublic long getDownloaded()
start()
.
public long getUploaded()
start()
.
public long getRemaining()
public long getDownSpeed()
public long getUpSpeed()
public void setMaxDownloadSpeed(long maximum)
maximum
is zero or negative, the speed capping limit will
be lifted.
maximum
- the maximum number of bytes that should be downloaded from
peers per secondpublic void setMaxUploadSpeed(long maximum)
maximum
is zero or negative, the speed capping limit will
be lifted.
maximum
- the maximum number of bytes that should be uploaded to peers
per secondpublic long getTimeRemaining()
-1
, the time is
unknown. This will be returned when the downloading speed is at 0.
-1
if the value is not knownpublic long getDiscarded()
public int getConnectedPeers()
public int getSeeds()
-1
,
the tracker does not support the distribution of this informationgetPeers()
public int getPeers()
-1
, the tracker does not support the
distribution of this informationgetSeeds()
public TorrentFile getTorrentFile()
TorrentFile
that initialized thispublic int getState()
ITorrentStateListener
interface.
ITorrentStateListener.STARTED
,
ITorrentStateListener.EXCHANGING
,
ITorrentStateListener.STOPPED
,
ITorrentStateListener.FINISHED
,
ITorrentStateListener.HASH_CHECKING
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |