Package com.biglybt.core.util
Class TorrentUtils.torrentDelegate
- java.lang.Object
-
- com.biglybt.core.logging.LogRelation
-
- com.biglybt.core.util.TorrentUtils.torrentDelegate
-
- All Implemented Interfaces:
TOTorrent
,TorrentUtils.ExtendedTorrent
- Enclosing class:
- TorrentUtils
public static class TorrentUtils.torrentDelegate extends LogRelation implements TorrentUtils.ExtendedTorrent
-
-
Field Summary
Fields Modifier and Type Field Description private TOTorrent
delegate
private java.io.File
file
private boolean
fluff_dirty
private long
last_pieces_read_time
private java.net.URL
url_mod_last_post
private java.net.URL
url_mod_last_pre
private int
url_mod_last_seq
private TOTorrentAnnounceURLGroup
urlg_mod_last_post
private java.util.List<java.net.URL>
urlg_mod_last_pre
private int
urlg_mod_last_seq
-
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
torrentDelegate(TOTorrent _delegate, java.io.File _file)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(TOTorrentListener l)
protected void
discardPieces(long now, boolean force)
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 methodTOTorrentAnnounceURLGroup
getAnnounceURLGroupSupport()
java.net.URL
getAnnounceURLSupport()
byte[]
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()
java.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()
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.byte[][]
peekPieces()
peeks the pieces, will return null if they are discardedvoid
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)
protected boolean[]
restoreState(boolean do_pieces, boolean do_fluff)
monitor must be held before calling meTOTorrent
selectHybridHashType(int type)
void
serialiseToBEncodedFile(java.io.File target_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 target_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
setDiscardFluff(boolean discard)
void
setHashOverride(byte[] hash)
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 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 com.biglybt.core.logging.LogRelation
propogatedRelationText, queryForClass
-
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
-
delegate
private final TOTorrent delegate
-
file
private final java.io.File file
-
fluff_dirty
private boolean fluff_dirty
-
last_pieces_read_time
private long last_pieces_read_time
-
url_mod_last_pre
private java.net.URL url_mod_last_pre
-
url_mod_last_post
private java.net.URL url_mod_last_post
-
url_mod_last_seq
private int url_mod_last_seq
-
urlg_mod_last_pre
private java.util.List<java.net.URL> urlg_mod_last_pre
-
urlg_mod_last_post
private TOTorrentAnnounceURLGroup urlg_mod_last_post
-
urlg_mod_last_seq
private int urlg_mod_last_seq
-
-
Constructor Detail
-
torrentDelegate
protected torrentDelegate(TOTorrent _delegate, java.io.File _file)
-
-
Method Detail
-
setDiscardFluff
public void setDiscardFluff(boolean discard)
- Specified by:
setDiscardFluff
in interfaceTorrentUtils.ExtendedTorrent
-
getName
public byte[] getName()
Description copied from interface:TOTorrent
Get the name of the torrent
-
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:
-
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:
-
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
-
getAnnounceURLSupport
public java.net.URL getAnnounceURLSupport()
-
setAnnounceURL
public boolean setAnnounceURL(java.net.URL url)
- Specified by:
setAnnounceURL
in interfaceTOTorrent
- Returns:
- true-changed; false-not changed
-
getAnnounceURLGroupSupport
public TOTorrentAnnounceURLGroup getAnnounceURLGroupSupport()
-
discardPieces
protected void discardPieces(long now, boolean force)
-
getPieces
public byte[][] getPieces() throws TOTorrentException
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.- Specified by:
getPieces
in interfaceTOTorrent
- Returns:
- Throws:
TOTorrentException
-
restoreState
protected boolean[] restoreState(boolean do_pieces, boolean do_fluff) throws TOTorrentException
monitor must be held before calling me- Parameters:
do_pieces
-do_fluff
-- Throws:
TOTorrentException
-
peekPieces
public byte[][] peekPieces() throws TOTorrentException
peeks the pieces, will return null if they are discarded- Specified by:
peekPieces
in interfaceTorrentUtils.ExtendedTorrent
- Returns:
- Throws:
TOTorrentException
-
setPieces
public void setPieces(byte[][] pieces) throws TOTorrentException
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!- Specified by:
setPieces
in interfaceTOTorrent
- Throws:
TOTorrentException
-
getPieceLength
public long getPieceLength()
Description copied from interface:TOTorrent
Returns the piece length used for the torrent- Specified by:
getPieceLength
in interfaceTOTorrent
- Returns:
-
getNumberOfPieces
public int getNumberOfPieces()
- Specified by:
getNumberOfPieces
in interfaceTOTorrent
-
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
-
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
-
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
-
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 target_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 target_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
-
print
public void print()
Description copied from interface:TOTorrent
A diagnostic method for dumping the tracker contents to "stdout"
-
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.
-
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
-
-