org.gudy.azureus2.core3.torrent
Interface TOTorrent

All Known Subinterfaces:
TorrentUtils.ExtendedTorrent
All Known Implementing Classes:
DownloadManagerStateImpl.CachedStateWrapper, LWSTorrent, TorrentUtils.torrentDelegate, TOTorrentCreateImpl, TOTorrentDeserialiseImpl, TOTorrentImpl, TRHostExternalTorrent

public interface TOTorrent


Field Summary
static String AZUREUS_PRIVATE_PROPERTIES
          These ones are *not* exportable to the world
static String AZUREUS_PROPERTIES
          A Map additional property defined for holding AZ specific properties that are deemed to be exportable to the world
static String DEFAULT_IGNORE_FILES
           
static String ENCODING_ACTUALLY_UTF8_KEYS
           
 
Method Summary
 void addListener(TOTorrentListener l)
           
 byte[] getAdditionalByteArrayProperty(String name)
           
 List getAdditionalListProperty(String name)
           
 Long getAdditionalLongProperty(String name)
           
 Map getAdditionalMapProperty(String name)
           
 Object getAdditionalProperty(String name)
           
 String getAdditionalStringProperty(String name)
           
 URL getAnnounceURL()
          A torrent must have a URL that identifies the tracker.
 TOTorrentAnnounceURLGroup getAnnounceURLGroup()
          When a group of sets of trackers is defined their URLs are accessed via this method
 byte[] getComment()
          Comment is an optional torrent property
 byte[] getCreatedBy()
           
 long getCreationDate()
          Gets the creation date of the torrent.
 int getFileCount()
           
 TOTorrentFile[] getFiles()
          A torrent consists of one or more files.
 byte[] getHash()
          A torrent has a unique SHA1 (20 byte) hash that is computed from some of its contents.
 HashWrapper getHashWrapper()
          convenience method to get a wrapped hash for performance purposes
 AEMonitor getMonitor()
           
 byte[] getName()
          Get the name of the torrent
 int getNumberOfPieces()
           
 long getPieceLength()
          Returns the piece length used for the torrent
 byte[][] getPieces()
           
 boolean getPrivate()
           
 long getSize()
           
 String getUTF8Name()
          Retrieves the utf8 name of the torrent ONLY if the torrent specified one in it's info map.
 boolean hasSameHashAs(TOTorrent other)
          compares two torrents by hash
 boolean isCreated()
           
 boolean isDecentralised()
          This method provides access to the SHA1 hash values (20 bytes each) that correspond to the pieces of the torrent.
 boolean isSimpleTorrent()
          A "simple torrent" is one that consists of a single file on its own (i.e.
 void print()
          A diagnostic method for dumping the tracker contents to "stdout"
 void removeAdditionalProperties()
          remove all additional properties to clear out the torrent
 void removeAdditionalProperty(String name)
           
 void removeListener(TOTorrentListener l)
           
 void serialiseToBEncodedFile(File file)
          This method will serialise a torrent using the standard "b-encoding" mechanism into a file
 Map serialiseToMap()
          This method will serialise a torrent into a Map consistent with that used by the "b-encoding" routines defined elsewhere
 void serialiseToXMLFile(File file)
          This method will serialise a torrent using an XML encoding to a file
 void setAdditionalByteArrayProperty(String name, byte[] value)
           
 void setAdditionalListProperty(String name, List value)
           
 void setAdditionalLongProperty(String name, Long value)
           
 void setAdditionalMapProperty(String name, Map value)
           
 void setAdditionalProperty(String name, Object value)
          set an arbitrary property.
 void setAdditionalStringProperty(String name, String value)
          The additional properties are used for holding non-core data for Azureus' own user
 boolean setAnnounceURL(URL url)
           
 void setComment(String comment)
           
 void setCreatedBy(byte[] cb)
           
 void setCreationDate(long date)
           
 void setHashOverride(byte[] hash)
          Only supported for decentralised torrents, allows an alternative hash to be used for them in the DHT
 void setPieces(byte[][] pieces)
          This method exists to support the temporary discarding of piece hashes to conserver memory.
 void setPrivate(boolean _private)
          Note - changing the private attribute CHANGES THE TORRENT HASH
 

Field Detail

DEFAULT_IGNORE_FILES

static final String DEFAULT_IGNORE_FILES
See Also:
Constant Field Values

AZUREUS_PROPERTIES

static final String AZUREUS_PROPERTIES
A Map additional property defined for holding AZ specific properties that are deemed to be exportable to the world

See Also:
Constant Field Values

AZUREUS_PRIVATE_PROPERTIES

static final String AZUREUS_PRIVATE_PROPERTIES
These ones are *not* exportable to the world

See Also:
Constant Field Values

ENCODING_ACTUALLY_UTF8_KEYS

static final String ENCODING_ACTUALLY_UTF8_KEYS
See Also:
Constant Field Values
Method Detail

getName

byte[] getName()
Get the name of the torrent

Returns:

isSimpleTorrent

boolean isSimpleTorrent()
A "simple torrent" is one that consists of a single file on its own (i.e. not in a nested directory).

Returns:

getComment

byte[] getComment()
Comment is an optional torrent property

Returns:

setComment

void setComment(String comment)

getCreationDate

long getCreationDate()
Gets the creation date of the torrent. Optional property, 0 returned if not set

Returns:

setCreationDate

void setCreationDate(long date)

getCreatedBy

byte[] getCreatedBy()

setCreatedBy

void setCreatedBy(byte[] cb)

isCreated

boolean isCreated()

getAnnounceURL

URL getAnnounceURL()
A torrent must have a URL that identifies the tracker. This method returns it. However an extension to this exists to allow multiple trackers, and their backups, to be defined. See below

Returns:

setAnnounceURL

boolean setAnnounceURL(URL url)
Parameters:
url -
Returns:
true-changed; false-not changed

getAnnounceURLGroup

TOTorrentAnnounceURLGroup getAnnounceURLGroup()
When a group of sets of trackers is defined their URLs are accessed via this method

Returns:
the group, always present, which may have 0 members

isDecentralised

boolean isDecentralised()
This method provides access to the SHA1 hash values (20 bytes each) that correspond to the pieces of the torrent.

Returns:
Throws:
can - fail if re-reading of piece hashes for space spacing fails

getPieces

byte[][] getPieces()
                   throws TOTorrentException
Throws:
TOTorrentException

setPieces

void setPieces(byte[][] pieces)
               throws TOTorrentException
This method exists to support the temporary discarding of piece hashes to conserver memory. It should only be used with care!

Parameters:
pieces -
Throws:
TOTorrentException

getPieceLength

long getPieceLength()
Returns the piece length used for the torrent

Returns:

getNumberOfPieces

int getNumberOfPieces()

getSize

long getSize()

getFileCount

int getFileCount()

getFiles

TOTorrentFile[] getFiles()
A torrent consists of one or more files. These are accessed via this method.

Returns:

getHash

byte[] getHash()
               throws TOTorrentException
A torrent has a unique SHA1 (20 byte) hash that is computed from some of its contents. It is used, for example, when contacting a tracker to identify the torrent.

Returns:
Throws:
TOTorrentException

getHashWrapper

HashWrapper getHashWrapper()
                           throws TOTorrentException
convenience method to get a wrapped hash for performance purposes

Returns:
Throws:
TOTorrentException

setHashOverride

void setHashOverride(byte[] hash)
                     throws TOTorrentException
Only supported for decentralised torrents, allows an alternative hash to be used for them in the DHT

Parameters:
hash -
Throws:
TOTorrentException

hasSameHashAs

boolean hasSameHashAs(TOTorrent other)
compares two torrents by hash

Parameters:
other -
Returns:

getPrivate

boolean getPrivate()

setPrivate

void setPrivate(boolean _private)
                throws TOTorrentException
Note - changing the private attribute CHANGES THE TORRENT HASH

Parameters:
_private -
Throws:
TOTorrentException

setAdditionalStringProperty

void setAdditionalStringProperty(String name,
                                 String value)
The additional properties are used for holding non-core data for Azureus' own user

Parameters:
name - name of the property (e.g. "encoding")
value - value. This will be encoded with default encoding

getAdditionalStringProperty

String getAdditionalStringProperty(String name)

setAdditionalByteArrayProperty

void setAdditionalByteArrayProperty(String name,
                                    byte[] value)

getAdditionalByteArrayProperty

byte[] getAdditionalByteArrayProperty(String name)

setAdditionalLongProperty

void setAdditionalLongProperty(String name,
                               Long value)

getAdditionalLongProperty

Long getAdditionalLongProperty(String name)

setAdditionalListProperty

void setAdditionalListProperty(String name,
                               List value)

getAdditionalListProperty

List getAdditionalListProperty(String name)

setAdditionalMapProperty

void setAdditionalMapProperty(String name,
                              Map value)

getAdditionalMapProperty

Map getAdditionalMapProperty(String name)

getAdditionalProperty

Object getAdditionalProperty(String name)

setAdditionalProperty

void setAdditionalProperty(String name,
                           Object value)
set an arbitrary property. Make sure its compatible with bencoding!


removeAdditionalProperty

void removeAdditionalProperty(String name)

removeAdditionalProperties

void removeAdditionalProperties()
remove all additional properties to clear out the torrent


serialiseToBEncodedFile

void serialiseToBEncodedFile(File file)
                             throws TOTorrentException
This method will serialise a torrent using the standard "b-encoding" mechanism into a file

Parameters:
file -
Throws:
TOTorrentException

serialiseToMap

Map serialiseToMap()
                   throws TOTorrentException
This method will serialise a torrent into a Map consistent with that used by the "b-encoding" routines defined elsewhere

Returns:
Throws:
TOTorrentException

serialiseToXMLFile

void serialiseToXMLFile(File file)
                        throws TOTorrentException
This method will serialise a torrent using an XML encoding to a file

Parameters:
file -
Throws:
TOTorrentException

addListener

void addListener(TOTorrentListener l)

removeListener

void removeListener(TOTorrentListener l)

getMonitor

AEMonitor getMonitor()

print

void print()
A diagnostic method for dumping the tracker contents to "stdout"


getUTF8Name

String getUTF8Name()
Retrieves the utf8 name of the torrent ONLY if the torrent specified one in it's info map. Otherwise, returns null (you'll have to use getName() and decode it yourself)