Class TorrentImpl
- java.lang.Object
-
- com.biglybt.core.logging.LogRelation
-
- com.biglybt.pifimpl.local.torrent.TorrentImpl
-
- All Implemented Interfaces:
Torrent
public class TorrentImpl extends LogRelation implements Torrent
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
complete
private LocaleUtilDecoder
decoder
private static MagnetPlugin
magnet_plugin
private PluginInterface
pi
private TOTorrent
torrent
-
Constructor Summary
Constructors Constructor Description TorrentImpl(TOTorrent _torrent)
TorrentImpl(PluginInterface _pi, TOTorrent _torrent)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.String
decode(byte[] data)
java.lang.Object
getAdditionalProperty(java.lang.String name)
Access to top-level properties in the torrentjava.net.URL
getAnnounceURL()
TorrentAnnounceURLList
getAnnounceURLList()
get the announce list for multi-tracker torrents.Torrent
getClone()
java.lang.String
getComment()
java.lang.String
getCreatedBy()
long
getCreationDate()
UNIX epoch format in secondsprotected void
getDecoder()
java.lang.String
getEncoding()
TorrentFile[]
getFiles()
byte[]
getFullHash(int type)
byte[]
getHash()
v1 torrent hash or truncated v2 hash if v2 onlyjava.net.URL
getMagnetURI()
Gets the magnet URI for the torrent - throws exception if not availablejava.util.Map
getMapProperty(java.lang.String name)
Gets a previously set map valuejava.lang.String
getName()
long
getPieceCount()
byte[][]
getPieces()
long
getPieceSize()
java.lang.String
getPluginStringProperty(java.lang.String name)
Get a property specific to this pluginjava.lang.Object[]
getQueryableInterfaces()
Query this class for a reference to another class that it may holdjava.lang.String
getRelationText()
A short description of what your class holds that can be printed by the loggerlong
getSize()
If size is 0 then this is an "external" torrent and we only know its hash (and name constructed from hash).TOTorrent
getTorrent()
boolean
isComplete()
boolean
isDecentralised()
A decentralised torrent uses the DHT only as a "tracker"boolean
isDecentralisedBackupEnabled()
Decentralised backup permits the DHT to be used as a tracker when the "real" tracker is unavailableboolean
isDecentralisedBackupRequested()
boolean
isPrivate()
A private torrent is either explicitly private via info/private or has decentralised backup disabled and peer exchange disabledboolean
isSimpleTorrent()
Returns true if the torrent is a single file torrent, false if it is a multi file torrent.Torrent
removeAdditionalProperties()
Removal all non-standard properties (excluding plugin-properties below)void
save()
Saves the torrent to its persistent locationvoid
setAnnounceURL(java.net.URL url)
void
setComment(java.lang.String comment)
void
setComplete(java.io.File data_dir)
sets the torrent complete - i.e.void
setDecentralisedBackupRequested(boolean requested)
By default torrents with OK trackers are not tracked in the DHT.void
setDefaultEncoding()
void
setEncoding(java.lang.String encoding)
void
setMapProperty(java.lang.String name, java.util.Map value)
Sets a map property in the torrent, retrievable via getMapPropertyvoid
setPluginStringProperty(java.lang.String name, java.lang.String value)
Set a property specific to this pluginvoid
setPrivate(boolean priv)
protected void
updated()
boolean
wasCreatedByUs()
byte[]
writeToBEncodedData()
void
writeToFile(java.io.File file)
java.util.Map
writeToMap()
-
Methods inherited from class com.biglybt.core.logging.LogRelation
propogatedRelationText, queryForClass
-
-
-
-
Field Detail
-
magnet_plugin
private static MagnetPlugin magnet_plugin
-
pi
private PluginInterface pi
-
torrent
private TOTorrent torrent
-
decoder
private LocaleUtilDecoder decoder
-
complete
private boolean complete
-
-
Constructor Detail
-
TorrentImpl
public TorrentImpl(TOTorrent _torrent)
-
TorrentImpl
public TorrentImpl(PluginInterface _pi, TOTorrent _torrent)
-
-
Method Detail
-
getAnnounceURL
public java.net.URL getAnnounceURL()
- Specified by:
getAnnounceURL
in interfaceTorrent
-
setAnnounceURL
public void setAnnounceURL(java.net.URL url)
- Specified by:
setAnnounceURL
in interfaceTorrent
-
getAnnounceURLList
public TorrentAnnounceURLList getAnnounceURLList()
Description copied from interface:Torrent
get the announce list for multi-tracker torrents. Will always be present but may contain 0 sets which means that this is not a multi-tracker torrent- Specified by:
getAnnounceURLList
in interfaceTorrent
- Returns:
-
getTorrent
public TOTorrent getTorrent()
-
isDecentralised
public boolean isDecentralised()
Description copied from interface:Torrent
A decentralised torrent uses the DHT only as a "tracker"- Specified by:
isDecentralised
in interfaceTorrent
- Returns:
-
isDecentralisedBackupEnabled
public boolean isDecentralisedBackupEnabled()
Description copied from interface:Torrent
Decentralised backup permits the DHT to be used as a tracker when the "real" tracker is unavailable- Specified by:
isDecentralisedBackupEnabled
in interfaceTorrent
- Returns:
-
setDecentralisedBackupRequested
public void setDecentralisedBackupRequested(boolean requested)
Description copied from interface:Torrent
By default torrents with OK trackers are not tracked in the DHT. This allows a specific torrent to be marked so that it will be- Specified by:
setDecentralisedBackupRequested
in interfaceTorrent
-
isDecentralisedBackupRequested
public boolean isDecentralisedBackupRequested()
- Specified by:
isDecentralisedBackupRequested
in interfaceTorrent
-
isPrivate
public boolean isPrivate()
Description copied from interface:Torrent
A private torrent is either explicitly private via info/private or has decentralised backup disabled and peer exchange disabled
-
setPrivate
public void setPrivate(boolean priv)
- Specified by:
setPrivate
in interfaceTorrent
-
wasCreatedByUs
public boolean wasCreatedByUs()
- Specified by:
wasCreatedByUs
in interfaceTorrent
- Returns:
-
getMagnetURI
public java.net.URL getMagnetURI() throws TorrentException
Description copied from interface:Torrent
Gets the magnet URI for the torrent - throws exception if not available- Specified by:
getMagnetURI
in interfaceTorrent
- Returns:
- Throws:
TorrentException
-
getHash
public byte[] getHash()
Description copied from interface:Torrent
v1 torrent hash or truncated v2 hash if v2 only
-
getFullHash
public byte[] getFullHash(int type)
- Specified by:
getFullHash
in interfaceTorrent
- Returns:
- v2 torrent hash if hybrid or v2 only torrent
-
getSize
public long getSize()
Description copied from interface:Torrent
If size is 0 then this is an "external" torrent and we only know its hash (and name constructed from hash). e.g. we don't know file details
-
getComment
public java.lang.String getComment()
- Specified by:
getComment
in interfaceTorrent
-
setComment
public void setComment(java.lang.String comment)
- Specified by:
setComment
in interfaceTorrent
-
getCreationDate
public long getCreationDate()
Description copied from interface:Torrent
UNIX epoch format in seconds- Specified by:
getCreationDate
in interfaceTorrent
-
getCreatedBy
public java.lang.String getCreatedBy()
- Specified by:
getCreatedBy
in interfaceTorrent
-
getPieceSize
public long getPieceSize()
- Specified by:
getPieceSize
in interfaceTorrent
-
getPieceCount
public long getPieceCount()
- Specified by:
getPieceCount
in interfaceTorrent
-
getFiles
public TorrentFile[] getFiles()
-
getDecoder
protected void getDecoder()
-
getEncoding
public java.lang.String getEncoding()
- Specified by:
getEncoding
in interfaceTorrent
-
setEncoding
public void setEncoding(java.lang.String encoding) throws TorrentEncodingException
- Specified by:
setEncoding
in interfaceTorrent
- Throws:
TorrentEncodingException
-
setDefaultEncoding
public void setDefaultEncoding() throws TorrentEncodingException
- Specified by:
setDefaultEncoding
in interfaceTorrent
- Throws:
TorrentEncodingException
-
decode
protected java.lang.String decode(byte[] data)
-
getAdditionalProperty
public java.lang.Object getAdditionalProperty(java.lang.String name)
Description copied from interface:Torrent
Access to top-level properties in the torrent- Specified by:
getAdditionalProperty
in interfaceTorrent
- Returns:
-
removeAdditionalProperties
public Torrent removeAdditionalProperties()
Description copied from interface:Torrent
Removal all non-standard properties (excluding plugin-properties below)- Specified by:
removeAdditionalProperties
in interfaceTorrent
- Returns:
-
setPluginStringProperty
public void setPluginStringProperty(java.lang.String name, java.lang.String value)
Description copied from interface:Torrent
Set a property specific to this plugin- Specified by:
setPluginStringProperty
in interfaceTorrent
-
getPluginStringProperty
public java.lang.String getPluginStringProperty(java.lang.String name)
Description copied from interface:Torrent
Get a property specific to this plugin- Specified by:
getPluginStringProperty
in interfaceTorrent
- Returns:
-
setMapProperty
public void setMapProperty(java.lang.String name, java.util.Map value)
Description copied from interface:Torrent
Sets a map property in the torrent, retrievable via getMapProperty- Specified by:
setMapProperty
in interfaceTorrent
- Parameters:
name
- should be unique across plugins (i.e. prefix it with something unique)value
- bencodable Map value
-
getMapProperty
public java.util.Map getMapProperty(java.lang.String name)
Description copied from interface:Torrent
Gets a previously set map value- Specified by:
getMapProperty
in interfaceTorrent
- Parameters:
name
- should be unique across plugins (i.e. prefix it with something unique)- Returns:
- See Also:
Torrent.setMapProperty(java.lang.String,java.util.Map)
-
writeToMap
public java.util.Map writeToMap() throws TorrentException
- Specified by:
writeToMap
in interfaceTorrent
- Throws:
TorrentException
-
writeToBEncodedData
public byte[] writeToBEncodedData() throws TorrentException
- Specified by:
writeToBEncodedData
in interfaceTorrent
- Throws:
TorrentException
-
writeToFile
public void writeToFile(java.io.File file) throws TorrentException
- Specified by:
writeToFile
in interfaceTorrent
- Throws:
TorrentException
-
updated
protected void updated()
-
save
public void save() throws TorrentException
Description copied from interface:Torrent
Saves the torrent to its persistent location- Specified by:
save
in interfaceTorrent
- Throws:
TorrentException
-
setComplete
public void setComplete(java.io.File data_dir) throws TorrentException
Description copied from interface:Torrent
sets the torrent complete - i.e. ready for seeding. Doing this avoids a recheck on torrent addition- Specified by:
setComplete
in interfaceTorrent
- Throws:
TorrentException
-
isComplete
public boolean isComplete()
- Specified by:
isComplete
in interfaceTorrent
-
getRelationText
public java.lang.String getRelationText()
Description copied from class:LogRelation
A short description of what your class holds that can be printed by the logger- Overrides:
getRelationText
in classLogRelation
- Returns:
-
getQueryableInterfaces
public java.lang.Object[] getQueryableInterfaces()
Description copied from class:LogRelation
Query this class for a reference to another class that it may hold- Overrides:
getQueryableInterfaces
in classLogRelation
- Returns:
- If found, the class desired. Otherwise, null.
-
isSimpleTorrent
public boolean isSimpleTorrent()
Description copied from interface:Torrent
Returns true if the torrent is a single file torrent, false if it is a multi file torrent.- Specified by:
isSimpleTorrent
in interfaceTorrent
-
getClone
public Torrent getClone() throws TorrentException
- Specified by:
getClone
in interfaceTorrent
- Throws:
TorrentException
-
-