public class Torrent extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Torrent.Builder
A builder to create new instances of
Torrent |
| Constructor and Description |
|---|
Torrent(Torrent.Builder builder)
Creates a new Torrent.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addDiskJob(IDiskJob task)
Adds a task to the IOManager of this torrent
|
void |
addPeer(Peer peer)
Adds a peer to the torrent if not already registered to the torrent.
|
void |
addUploadedBytes(long l)
Adds the amount of bytes to the uploaded count
|
void |
checkProgress()
Calculates the current progress based on all available files on the HDD
|
boolean |
equals(Object obj) |
String |
getDisplayName() |
long |
getDownloadedBytes()
The amount of bytes downloaded
|
int |
getDownloadRate()
Sums the download rates of all peers.
|
AbstractFileSet |
getFileSet()
Gets the files which are being downloaded within this torrent.
|
String |
getHash()
Gets the
getHashArray() formatted as hexadecimal. |
byte[] |
getHashArray()
Gets the 20 byte BTIH hash of the torrent.
|
int |
getLeecherCount()
Counts the amount of peers which don't have all pieces yet.
|
Optional<MetadataFileSet> |
getMetadata() |
List<Peer> |
getPeers()
Creates a copy of the list of connected peers.
|
IPieceSelector |
getPieceSelector()
The regulator which is managing this download
|
int |
getSeedCount()
Counts the amount of peers which have all pieces.
|
long |
getUploadedBytes()
The amount of bytes we have uploaded this session
|
int |
getUploadRate()
Sums the upload rates of all peers.
|
int |
hashCode() |
boolean |
isDownloadingMetadata()
If the Torrent should be downloading the metadata information.
|
void |
onReceivedBlock(AbstractFileSet fileSet,
int index,
int offset,
byte[] data)
Tells the torrent to save a block of data
|
void |
pollRates()
Polls all peers transfer speeds.
|
void |
removePeer(Peer peer)
Removes a peer from the torrent.
|
void |
setFileSet(AbstractFileSet files)
Sets the current set of files this torrent is downloading.
|
void |
setMetadata(MetadataFileSet metadata)
Sets the associated metadata file of the torrent
|
void |
setPieceSelector(IPieceSelector downloadRegulator) |
String |
toString() |
public Torrent(Torrent.Builder builder)
builder - The builder with the components for the torrent.public void addPeer(Peer peer) throws IOException
MessageBitfield or one or more MessageHave.peer - The peer to add.IOExceptionpublic void removePeer(Peer peer)
peer - the peer to remove.public String getDisplayName()
public byte[] getHashArray()
public String getHash()
getHashArray() formatted as hexadecimal.getHashArray()public boolean isDownloadingMetadata()
true when the torrent is currently downloading the metadata, otherwise falsepublic void onReceivedBlock(AbstractFileSet fileSet, int index, int offset, byte[] data)
fileSet - The fileset for which the block of data has been received.index - The piece indexoffset - The offset within the piecedata - The bytes to be storedpublic void addDiskJob(IDiskJob task)
task - The task to addpublic void checkProgress()
public void addUploadedBytes(long l)
l - The amount of bytes to addpublic void setFileSet(AbstractFileSet files)
files - The file set.public void setMetadata(MetadataFileSet metadata)
metadata - the metadata which is backing this torrentpublic Optional<MetadataFileSet> getMetadata()
public void pollRates()
public AbstractFileSet getFileSet()
setFileSet(AbstractFileSet).setFileSet(AbstractFileSet)public int getDownloadRate()
pollRates()public int getUploadRate()
pollRates()public int getSeedCount()
public int getLeecherCount()
public List<Peer> getPeers()
public long getDownloadedBytes()
public long getUploadedBytes()
public IPieceSelector getPieceSelector()
public void setPieceSelector(IPieceSelector downloadRegulator)
Copyright © 2016. All rights reserved.