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
FieldsModifier and TypeFieldDescriptionprivate final TOTorrent
private final File
private boolean
private long
private URL
private URL
private int
private TOTorrentAnnounceURLGroup
private int
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 -
Method Summary
Modifier and TypeMethodDescriptionvoid
protected void
discardPieces
(long now, boolean force) byte[]
getAdditionalProperty
(String name) A torrent must have a URL that identifies the tracker.When a group of sets of trackers is defined their URLs are accessed via this methodbyte[]
Comment is an optional torrent propertybyte[]
long
Gets the creation date of the torrent.int
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 hashconvenience method to get a wrapped hash for performance purposesbyte[]
getName()
Get the name of the torrentint
long
Returns the piece length used for the torrentbyte[][]
This method provides access to the SHA1/SHA256 hash values (20/32 bytes each) that correspond to the pieces of the torrent.boolean
Object[]
Query this class for a reference to another class that it may holdA short description of what your class holds that can be printed by the loggerlong
getSize()
int
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
boolean
Is the torrent in a fit state to export and share?boolean
A "simple torrent" is one that consists of a single file on its own (i.e.boolean
byte[][]
peeks the pieces, will return null if they are discardedvoid
print()
A diagnostic method for dumping the tracker contents to "stdout"void
remove all additional properties to clear out the torrentvoid
void
protected boolean[]
restoreState
(boolean do_pieces, boolean do_fluff) monitor must be held before calling meselectHybridHashType
(int type) void
serialiseToBEncodedFile
(File target_file) This method will serialise a torrent using the standard "b-encoding" mechanism into a fileThis method will serialise a torrent into a Map consistent with that used by the "b-encoding" routines defined elsewherevoid
serialiseToXMLFile
(File target_file) This method will serialise a torrent using an XML encoding to a filevoid
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 userboolean
setAnnounceURL
(URL url) void
setComment
(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 HASHsetSimpleTorrentDisabled
(boolean disabled) void
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 Details
-
delegate
-
file
-
fluff_dirty
private boolean fluff_dirty -
last_pieces_read_time
private long last_pieces_read_time -
url_mod_last_pre
-
url_mod_last_post
-
url_mod_last_seq
private int url_mod_last_seq -
urlg_mod_last_pre
-
urlg_mod_last_post
-
urlg_mod_last_seq
private int urlg_mod_last_seq
-
-
Constructor Details
-
torrentDelegate
-
-
Method Details
-
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
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
- Parameters:
from
-- 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
- 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
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
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
-
setAnnounceURL
- Specified by:
setAnnounceURL
in interfaceTOTorrent
- Parameters:
url
-- Returns:
- true-changed; false-not changed
-
getAnnounceURLGroupSupport
-
discardPieces
protected void discardPieces(long now, boolean force) -
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.- Specified by:
getPieces
in interfaceTOTorrent
- Returns:
- Throws:
TOTorrentException
-
restoreState
monitor must be held before calling me- Parameters:
do_pieces
-do_fluff
-- Throws:
TOTorrentException
-
peekPieces
peeks the pieces, will return null if they are discarded- Specified by:
peekPieces
in interfaceTorrentUtils.ExtendedTorrent
- Returns:
- Throws:
TOTorrentException
-
setPieces
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
- Parameters:
pieces
-- 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
-
getSize
public long getSize() -
getFileCount
public int getFileCount()- Specified by:
getFileCount
in interfaceTOTorrent
-
getFiles
Description copied from interface:TOTorrent
A torrent consists of one or more files. These are accessed via this method. -
getHash
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
- Specified by:
getFullHash
in interfaceTOTorrent
- Returns:
- SHA1 hash for v1/hybrid torrents, SHA256 hash for hybrid/v2 torrents
- Throws:
TOTorrentException
-
getHashWrapper
Description copied from interface:TOTorrent
convenience method to get a wrapped hash for performance purposes- Specified by:
getHashWrapper
in interfaceTOTorrent
- Returns:
- Throws:
TOTorrentException
-
selectHybridHashType
- Specified by:
selectHybridHashType
in interfaceTOTorrent
- Throws:
TOTorrentException
-
setHashOverride
- Specified by:
setHashOverride
in interfaceTOTorrent
- Throws:
TOTorrentException
-
setSimpleTorrentDisabled
- Specified by:
setSimpleTorrentDisabled
in interfaceTOTorrent
- Throws:
TOTorrentException
-
isSimpleTorrentDisabled
- Specified by:
isSimpleTorrentDisabled
in interfaceTOTorrent
- Throws:
TOTorrentException
-
getPrivate
public boolean getPrivate()- Specified by:
getPrivate
in interfaceTOTorrent
-
setPrivate
Description copied from interface:TOTorrent
Note - changing the private attribute CHANGES THE TORRENT HASH- Specified by:
setPrivate
in interfaceTOTorrent
- Parameters:
_private
-- Throws:
TOTorrentException
-
getSource
-
setSource
Description copied from interface:TOTorrent
Note - changing the source CHANGES THE TORRENT HASH- Specified by:
setSource
in interfaceTOTorrent
- Parameters:
str
-- Throws:
TOTorrentException
-
hasSameHashAs
Description copied from interface:TOTorrent
compares two torrents by hash- Specified by:
hasSameHashAs
in interfaceTOTorrent
- Parameters:
other
-- Returns:
-
setAdditionalStringProperty
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
- Specified by:
getAdditionalStringProperty
in interfaceTOTorrent
-
setAdditionalByteArrayProperty
- Specified by:
setAdditionalByteArrayProperty
in interfaceTOTorrent
-
getAdditionalByteArrayProperty
- Specified by:
getAdditionalByteArrayProperty
in interfaceTOTorrent
-
setAdditionalLongProperty
- Specified by:
setAdditionalLongProperty
in interfaceTOTorrent
-
getAdditionalLongProperty
- Specified by:
getAdditionalLongProperty
in interfaceTOTorrent
-
setAdditionalListProperty
- Specified by:
setAdditionalListProperty
in interfaceTOTorrent
-
getAdditionalListProperty
- Specified by:
getAdditionalListProperty
in interfaceTOTorrent
-
setAdditionalMapProperty
- Specified by:
setAdditionalMapProperty
in interfaceTOTorrent
-
getAdditionalMapProperty
- Specified by:
getAdditionalMapProperty
in interfaceTOTorrent
-
getAdditionalProperty
- Specified by:
getAdditionalProperty
in interfaceTOTorrent
-
setAdditionalProperty
Description copied from interface:TOTorrent
set an arbitrary property. Make sure its compatible with bencoding!- Specified by:
setAdditionalProperty
in interfaceTOTorrent
-
removeAdditionalProperty
- 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
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
- Parameters:
target_file
-- Throws:
TOTorrentException
-
serialiseToMap
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
Description copied from interface:TOTorrent
This method will serialise a torrent using an XML encoding to a file- Specified by:
serialiseToXMLFile
in interfaceTOTorrent
- Parameters:
target_file
-- Throws:
TOTorrentException
-
addListener
- Specified by:
addListener
in interfaceTOTorrent
-
removeListener
- Specified by:
removeListener
in interfaceTOTorrent
-
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
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
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
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
-