org.gudy.azureus2.pluginsimpl.local.torrent
Class TorrentImpl

java.lang.Object
  extended by org.gudy.azureus2.core3.logging.LogRelation
      extended by org.gudy.azureus2.pluginsimpl.local.torrent.TorrentImpl
All Implemented Interfaces:
Torrent

public class TorrentImpl
extends LogRelation
implements Torrent


Constructor Summary
TorrentImpl(PluginInterface _pi, TOTorrent _torrent)
           
TorrentImpl(TOTorrent _torrent)
           
 
Method Summary
protected  String decode(byte[] data)
           
 Object getAdditionalProperty(String name)
          Access to top-level properties in the torrent
 URL getAnnounceURL()
           
 TorrentAnnounceURLList getAnnounceURLList()
          get the announce list for multi-tracker torrents.
 Torrent getClone()
           
 String getComment()
           
 String getCreatedBy()
           
 long getCreationDate()
          UNIX epoch format in seconds
protected  void getDecoder()
           
 String getEncoding()
           
 TorrentFile[] getFiles()
           
 byte[] getHash()
           
 URL getMagnetURI()
          Gets the magnet URI for the torrent - throws exception if not available
 Map getMapProperty(String name)
          Gets a previously set map value
 String getName()
           
 long getPieceCount()
           
 byte[][] getPieces()
           
 long getPieceSize()
           
 String getPluginStringProperty(String name)
          Get a property specific to this plugin
 Object[] getQueryableInterfaces()
          Query this class for a reference to another class that it may hold
 String getRelationText()
          A short description of what your class holds that can be printed by the logger
 long 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 unavailable
 boolean isDecentralisedBackupRequested()
           
 boolean isPrivate()
          A private torrent is either explicitly private via info/private or has decentralised backup disabled and peer exchange disabled
 boolean 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 location
 void setAnnounceURL(URL url)
           
 void setComment(String comment)
           
 void setComplete(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(String encoding)
           
 void setMapProperty(String name, Map value)
          Sets a map property in the torrent, retrievable via getMapProperty
 void setPluginStringProperty(String name, String value)
          Set a property specific to this plugin
 void setPrivate(boolean priv)
           
protected  void updated()
           
 boolean wasCreatedByUs()
           
 byte[] writeToBEncodedData()
           
 void writeToFile(File file)
           
 Map writeToMap()
           
 
Methods inherited from class org.gudy.azureus2.core3.logging.LogRelation
propogatedRelationText, queryForClass, queryForClass
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TorrentImpl

public TorrentImpl(TOTorrent _torrent)

TorrentImpl

public TorrentImpl(PluginInterface _pi,
                   TOTorrent _torrent)
Method Detail

getName

public String getName()
Specified by:
getName in interface Torrent

getAnnounceURL

public URL getAnnounceURL()
Specified by:
getAnnounceURL in interface Torrent

setAnnounceURL

public void setAnnounceURL(URL url)
Specified by:
setAnnounceURL in interface Torrent

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 interface Torrent
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 interface Torrent
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 interface Torrent
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 interface Torrent

isDecentralisedBackupRequested

public boolean isDecentralisedBackupRequested()
Specified by:
isDecentralisedBackupRequested in interface Torrent

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

Specified by:
isPrivate in interface Torrent
Returns:

setPrivate

public void setPrivate(boolean priv)
Specified by:
setPrivate in interface Torrent

wasCreatedByUs

public boolean wasCreatedByUs()
Specified by:
wasCreatedByUs in interface Torrent
Returns:

getMagnetURI

public 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 interface Torrent
Returns:
Throws:
TorrentException

getHash

public byte[] getHash()
Specified by:
getHash in interface 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

Specified by:
getSize in interface Torrent
Returns:

getComment

public String getComment()
Specified by:
getComment in interface Torrent

setComment

public void setComment(String comment)
Specified by:
setComment in interface Torrent

getCreationDate

public long getCreationDate()
Description copied from interface: Torrent
UNIX epoch format in seconds

Specified by:
getCreationDate in interface Torrent

getCreatedBy

public String getCreatedBy()
Specified by:
getCreatedBy in interface Torrent

getPieceSize

public long getPieceSize()
Specified by:
getPieceSize in interface Torrent

getPieceCount

public long getPieceCount()
Specified by:
getPieceCount in interface Torrent

getPieces

public byte[][] getPieces()
Specified by:
getPieces in interface Torrent

getFiles

public TorrentFile[] getFiles()
Specified by:
getFiles in interface Torrent

getDecoder

protected void getDecoder()

getEncoding

public String getEncoding()
Specified by:
getEncoding in interface Torrent

setEncoding

public void setEncoding(String encoding)
                 throws TorrentEncodingException
Specified by:
setEncoding in interface Torrent
Throws:
TorrentEncodingException

setDefaultEncoding

public void setDefaultEncoding()
                        throws TorrentEncodingException
Specified by:
setDefaultEncoding in interface Torrent
Throws:
TorrentEncodingException

decode

protected String decode(byte[] data)

getAdditionalProperty

public Object getAdditionalProperty(String name)
Description copied from interface: Torrent
Access to top-level properties in the torrent

Specified by:
getAdditionalProperty in interface Torrent
Returns:

removeAdditionalProperties

public Torrent removeAdditionalProperties()
Description copied from interface: Torrent
Removal all non-standard properties (excluding plugin-properties below)

Specified by:
removeAdditionalProperties in interface Torrent
Returns:

setPluginStringProperty

public void setPluginStringProperty(String name,
                                    String value)
Description copied from interface: Torrent
Set a property specific to this plugin

Specified by:
setPluginStringProperty in interface Torrent

getPluginStringProperty

public String getPluginStringProperty(String name)
Description copied from interface: Torrent
Get a property specific to this plugin

Specified by:
getPluginStringProperty in interface Torrent
Returns:

setMapProperty

public void setMapProperty(String name,
                           Map value)
Description copied from interface: Torrent
Sets a map property in the torrent, retrievable via getMapProperty

Specified by:
setMapProperty in interface Torrent
Parameters:
name - should be unique across plugins (i.e. prefix it with something unique)
value - bencodable Map value

getMapProperty

public Map getMapProperty(String name)
Description copied from interface: Torrent
Gets a previously set map value

Specified by:
getMapProperty in interface Torrent
Parameters:
name - should be unique across plugins (i.e. prefix it with something unique)
Returns:
See Also:
setMapProperty

writeToMap

public Map writeToMap()
               throws TorrentException
Specified by:
writeToMap in interface Torrent
Throws:
TorrentException

writeToBEncodedData

public byte[] writeToBEncodedData()
                           throws TorrentException
Specified by:
writeToBEncodedData in interface Torrent
Throws:
TorrentException

writeToFile

public void writeToFile(File file)
                 throws TorrentException
Specified by:
writeToFile in interface Torrent
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 interface Torrent
Throws:
TorrentException

setComplete

public void setComplete(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 interface Torrent
Throws:
TorrentException

isComplete

public boolean isComplete()
Specified by:
isComplete in interface Torrent

getRelationText

public 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 class LogRelation
Returns:

getQueryableInterfaces

public Object[] getQueryableInterfaces()
Description copied from class: LogRelation
Query this class for a reference to another class that it may hold

Overrides:
getQueryableInterfaces in class LogRelation
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 interface Torrent

getClone

public Torrent getClone()
                 throws TorrentException
Specified by:
getClone in interface Torrent
Throws:
TorrentException