Class TRHostExternalTorrent
- java.lang.Object
-
- com.biglybt.core.tracker.host.impl.TRHostExternalTorrent
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map
additional_properties
private java.net.URL
announce_url
private byte[]
hash
private HashWrapper
hash_wrapper
private byte[]
name
protected AEMonitor
this_mon
-
Fields inherited from interface com.biglybt.core.torrent.TOTorrent
AZUREUS_PRIVATE_PROPERTIES, AZUREUS_PROPERTIES, DEFAULT_IGNORE_FILES, ENCODING_ACTUALLY_UTF8_KEYS, TT_V1, TT_V1_V2, TT_V2
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
TRHostExternalTorrent(byte[] _hash, java.net.URL _announce_url)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(TOTorrentListener l)
void
addTorrentAnnounceURLSet(java.net.URL[] urls)
byte[]
getAdditionalByteArrayProperty(java.lang.String name)
java.util.List
getAdditionalListProperty(java.lang.String name)
java.lang.Long
getAdditionalLongProperty(java.lang.String name)
java.util.Map
getAdditionalMapProperty(java.lang.String name)
java.lang.Object
getAdditionalProperty(java.lang.String name)
java.lang.String
getAdditionalStringProperty(java.lang.String name)
java.net.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 methodbyte[]
getComment()
Comment is an optional torrent propertybyte[]
getCreatedBy()
long
getCreationDate()
Gets the creation date of the torrent.int
getFileCount()
TOTorrentFile[]
getFiles()
A torrent consists of one or more files.byte[]
getFullHash(int type)
byte[]
getHash()
For a V1 or hybrid torrent this returns the SHA1 hash For a V2 only torrent it returns the truncated SHA256 hashHashWrapper
getHashWrapper()
convenience method to get a wrapped hash for performance purposesAEMonitor
getMonitor()
byte[]
getName()
Get the name of the torrentint
getNumberOfPieces()
long
getPieceLength()
Returns the piece length used for the torrentbyte[][]
getPieces()
This method provides access to the SHA1/SHA256 hash values (20/32 bytes each) that correspond to the pieces of the torrent.boolean
getPrivate()
long
getSize()
java.lang.String
getSource()
int
getTorrentType()
java.lang.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 hashboolean
isCreated()
boolean
isDecentralised()
boolean
isExportable()
Is the torrent in a fit state to export and share?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 torrentvoid
removeAdditionalProperty(java.lang.String name)
void
removeListener(TOTorrentListener l)
TOTorrent
selectHybridHashType(int type)
void
serialiseToBEncodedFile(java.io.File file)
This method will serialise a torrent using the standard "b-encoding" mechanism into a filejava.util.Map
serialiseToMap()
This method will serialise a torrent into a Map consistent with that used by the "b-encoding" routines defined elsewherevoid
serialiseToXMLFile(java.io.File file)
This method will serialise a torrent using an XML encoding to a filevoid
setAdditionalByteArrayProperty(java.lang.String name, byte[] value)
void
setAdditionalListProperty(java.lang.String name, java.util.List value)
void
setAdditionalLongProperty(java.lang.String name, java.lang.Long value)
void
setAdditionalMapProperty(java.lang.String name, java.util.Map value)
void
setAdditionalProperty(java.lang.String name, java.lang.Object value)
set an arbitrary property.void
setAdditionalStringProperty(java.lang.String name, java.lang.String value)
The additional properties are used for holding non-core data for Azureus' own userboolean
setAnnounceURL(java.net.URL url)
void
setComment(java.lang.String comment)
void
setCreatedBy(byte[] cb)
void
setCreationDate(long date)
void
setHashOverride(byte[] hash)
void
setPieces(byte[][] b)
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 HASHvoid
setSource(java.lang.String str)
Note - changing the source CHANGES THE TORRENT HASHboolean
updateExportability(TOTorrent from)
Propagate exportability from another torrent to this one - has to have same hash.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.biglybt.core.torrent.TOTorrent
getEffectiveTorrentType, getTruncatedHash
-
-
-
-
Field Detail
-
name
private final byte[] name
-
hash
private final byte[] hash
-
hash_wrapper
private final HashWrapper hash_wrapper
-
announce_url
private final java.net.URL announce_url
-
additional_properties
protected final java.util.Map additional_properties
-
this_mon
protected final AEMonitor this_mon
-
-
Method Detail
-
getTorrentType
public int getTorrentType()
- Specified by:
getTorrentType
in interfaceTOTorrent
- Returns:
- One of the TT_ constants
-
isExportable
public boolean isExportable()
Description copied from interface:TOTorrent
Is the torrent in a fit state to export and share?- Specified by:
isExportable
in interfaceTOTorrent
- Returns:
-
updateExportability
public boolean updateExportability(TOTorrent from)
Description copied from interface:TOTorrent
Propagate exportability from another torrent to this one - has to have same hash. Required because an internal torrent can become exportable whilst the 'saved' (unexportable) original torrent is sitting there untouched...- Specified by:
updateExportability
in interfaceTOTorrent
- Returns:
-
getName
public byte[] getName()
Description copied from interface:TOTorrent
Get the name of the torrent
-
getUTF8Name
public java.lang.String getUTF8Name()
Description copied from interface:TOTorrent
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)- Specified by:
getUTF8Name
in interfaceTOTorrent
-
isSimpleTorrent
public boolean isSimpleTorrent()
Description copied from interface:TOTorrent
A "simple torrent" is one that consists of a single file on its own (i.e. not in a nested directory).- Specified by:
isSimpleTorrent
in interfaceTOTorrent
- Returns:
-
getComment
public byte[] getComment()
Description copied from interface:TOTorrent
Comment is an optional torrent property- Specified by:
getComment
in interfaceTOTorrent
- Returns:
-
setComment
public void setComment(java.lang.String comment)
- Specified by:
setComment
in interfaceTOTorrent
-
getCreationDate
public long getCreationDate()
Description copied from interface:TOTorrent
Gets the creation date of the torrent. Optional property, 0 returned if not set- Specified by:
getCreationDate
in interfaceTOTorrent
- Returns:
-
setCreationDate
public void setCreationDate(long date)
- Specified by:
setCreationDate
in interfaceTOTorrent
-
getCreatedBy
public byte[] getCreatedBy()
- Specified by:
getCreatedBy
in interfaceTOTorrent
-
setCreatedBy
public void setCreatedBy(byte[] cb)
- Specified by:
setCreatedBy
in interfaceTOTorrent
-
isDecentralised
public boolean isDecentralised()
- Specified by:
isDecentralised
in interfaceTOTorrent
-
getAnnounceURL
public java.net.URL getAnnounceURL()
Description copied from interface:TOTorrent
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- Specified by:
getAnnounceURL
in interfaceTOTorrent
- Returns:
-
setAnnounceURL
public boolean setAnnounceURL(java.net.URL url)
- Specified by:
setAnnounceURL
in interfaceTOTorrent
- Returns:
- true-changed; false-not changed
-
getAnnounceURLGroup
public TOTorrentAnnounceURLGroup getAnnounceURLGroup()
Description copied from interface:TOTorrent
When a group of sets of trackers is defined their URLs are accessed via this method- Specified by:
getAnnounceURLGroup
in interfaceTOTorrent
- Returns:
- the group, always present, which may have 0 members
-
addTorrentAnnounceURLSet
public void addTorrentAnnounceURLSet(java.net.URL[] urls)
-
getPieces
public byte[][] getPieces()
Description copied from interface:TOTorrent
This method provides access to the SHA1/SHA256 hash values (20/32 bytes each) that correspond to the pieces of the torrent.
-
setPieces
public void setPieces(byte[][] b)
Description copied from interface:TOTorrent
This method exists to support the temporary discarding of piece hashes to conserver memory. It should only be used with care!
-
getNumberOfPieces
public int getNumberOfPieces()
- Specified by:
getNumberOfPieces
in interfaceTOTorrent
-
getPieceLength
public long getPieceLength()
Description copied from interface:TOTorrent
Returns the piece length used for the torrent- Specified by:
getPieceLength
in interfaceTOTorrent
- Returns:
-
getFileCount
public int getFileCount()
- Specified by:
getFileCount
in interfaceTOTorrent
-
getFiles
public TOTorrentFile[] getFiles()
Description copied from interface:TOTorrent
A torrent consists of one or more files. These are accessed via this method.
-
getHash
public byte[] getHash() throws TOTorrentException
Description copied from interface:TOTorrent
For a V1 or hybrid torrent this returns the SHA1 hash For a V2 only torrent it returns the truncated SHA256 hash- Specified by:
getHash
in interfaceTOTorrent
- Returns:
- Throws:
TOTorrentException
-
getFullHash
public byte[] getFullHash(int type) throws TOTorrentException
- Specified by:
getFullHash
in interfaceTOTorrent
- Returns:
- SHA1 hash for v1/hybrid torrents, SHA256 hash for hybrid/v2 torrents
- Throws:
TOTorrentException
-
getHashWrapper
public HashWrapper getHashWrapper() throws TOTorrentException
Description copied from interface:TOTorrent
convenience method to get a wrapped hash for performance purposes- Specified by:
getHashWrapper
in interfaceTOTorrent
- Returns:
- Throws:
TOTorrentException
-
selectHybridHashType
public TOTorrent selectHybridHashType(int type) throws TOTorrentException
- Specified by:
selectHybridHashType
in interfaceTOTorrent
- Throws:
TOTorrentException
-
setHashOverride
public void setHashOverride(byte[] hash) throws TOTorrentException
- Specified by:
setHashOverride
in interfaceTOTorrent
- Throws:
TOTorrentException
-
getPrivate
public boolean getPrivate()
- Specified by:
getPrivate
in interfaceTOTorrent
-
setPrivate
public void setPrivate(boolean _private) throws TOTorrentException
Description copied from interface:TOTorrent
Note - changing the private attribute CHANGES THE TORRENT HASH- Specified by:
setPrivate
in interfaceTOTorrent
- Throws:
TOTorrentException
-
setSource
public void setSource(java.lang.String str) throws TOTorrentException
Description copied from interface:TOTorrent
Note - changing the source CHANGES THE TORRENT HASH- Specified by:
setSource
in interfaceTOTorrent
- Throws:
TOTorrentException
-
hasSameHashAs
public boolean hasSameHashAs(TOTorrent other)
Description copied from interface:TOTorrent
compares two torrents by hash- Specified by:
hasSameHashAs
in interfaceTOTorrent
- Returns:
-
setAdditionalStringProperty
public void setAdditionalStringProperty(java.lang.String name, java.lang.String value)
Description copied from interface:TOTorrent
The additional properties are used for holding non-core data for Azureus' own user- Specified by:
setAdditionalStringProperty
in interfaceTOTorrent
- Parameters:
name
- name of the property (e.g. "encoding")value
- value. This will be encoded with default encoding
-
getAdditionalStringProperty
public java.lang.String getAdditionalStringProperty(java.lang.String name)
- Specified by:
getAdditionalStringProperty
in interfaceTOTorrent
-
setAdditionalByteArrayProperty
public void setAdditionalByteArrayProperty(java.lang.String name, byte[] value)
- Specified by:
setAdditionalByteArrayProperty
in interfaceTOTorrent
-
getAdditionalByteArrayProperty
public byte[] getAdditionalByteArrayProperty(java.lang.String name)
- Specified by:
getAdditionalByteArrayProperty
in interfaceTOTorrent
-
setAdditionalLongProperty
public void setAdditionalLongProperty(java.lang.String name, java.lang.Long value)
- Specified by:
setAdditionalLongProperty
in interfaceTOTorrent
-
setAdditionalProperty
public void setAdditionalProperty(java.lang.String name, java.lang.Object value)
Description copied from interface:TOTorrent
set an arbitrary property. Make sure its compatible with bencoding!- Specified by:
setAdditionalProperty
in interfaceTOTorrent
-
getAdditionalLongProperty
public java.lang.Long getAdditionalLongProperty(java.lang.String name)
- Specified by:
getAdditionalLongProperty
in interfaceTOTorrent
-
setAdditionalListProperty
public void setAdditionalListProperty(java.lang.String name, java.util.List value)
- Specified by:
setAdditionalListProperty
in interfaceTOTorrent
-
getAdditionalListProperty
public java.util.List getAdditionalListProperty(java.lang.String name)
- Specified by:
getAdditionalListProperty
in interfaceTOTorrent
-
setAdditionalMapProperty
public void setAdditionalMapProperty(java.lang.String name, java.util.Map value)
- Specified by:
setAdditionalMapProperty
in interfaceTOTorrent
-
getAdditionalMapProperty
public java.util.Map getAdditionalMapProperty(java.lang.String name)
- Specified by:
getAdditionalMapProperty
in interfaceTOTorrent
-
getAdditionalProperty
public java.lang.Object getAdditionalProperty(java.lang.String name)
- Specified by:
getAdditionalProperty
in interfaceTOTorrent
-
removeAdditionalProperty
public void removeAdditionalProperty(java.lang.String name)
- Specified by:
removeAdditionalProperty
in interfaceTOTorrent
-
removeAdditionalProperties
public void removeAdditionalProperties()
Description copied from interface:TOTorrent
remove all additional properties to clear out the torrent- Specified by:
removeAdditionalProperties
in interfaceTOTorrent
-
serialiseToBEncodedFile
public void serialiseToBEncodedFile(java.io.File file) throws TOTorrentException
Description copied from interface:TOTorrent
This method will serialise a torrent using the standard "b-encoding" mechanism into a file- Specified by:
serialiseToBEncodedFile
in interfaceTOTorrent
- Throws:
TOTorrentException
-
serialiseToMap
public java.util.Map serialiseToMap() throws TOTorrentException
Description copied from interface:TOTorrent
This method will serialise a torrent into a Map consistent with that used by the "b-encoding" routines defined elsewhere- Specified by:
serialiseToMap
in interfaceTOTorrent
- Returns:
- Throws:
TOTorrentException
-
serialiseToXMLFile
public void serialiseToXMLFile(java.io.File file) throws TOTorrentException
Description copied from interface:TOTorrent
This method will serialise a torrent using an XML encoding to a file- Specified by:
serialiseToXMLFile
in interfaceTOTorrent
- Throws:
TOTorrentException
-
addListener
public void addListener(TOTorrentListener l)
- Specified by:
addListener
in interfaceTOTorrent
-
removeListener
public void removeListener(TOTorrentListener l)
- Specified by:
removeListener
in interfaceTOTorrent
-
getMonitor
public AEMonitor getMonitor()
- Specified by:
getMonitor
in interfaceTOTorrent
-
-