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 TOTorrentprivate final Fileprivate booleanprivate longprivate URLprivate URLprivate intprivate TOTorrentAnnounceURLGroupprivate intFields inherited from interface 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 TypeMethodDescriptionvoidprotected voiddiscardPieces(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[]longGets the creation date of the torrent.intgetFiles()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 torrentintlongReturns 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.booleanObject[]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 loggerlonggetSize()intRetrieves the utf8 name of the torrent ONLY if the torrent specified one in it's info map.booleanhasSameHashAs(TOTorrent other) compares two torrents by hashbooleanbooleanIs the torrent in a fit state to export and share?booleanA "simple torrent" is one that consists of a single file on its own (i.e.booleanbyte[][]peeks the pieces, will return null if they are discardedvoidprint()A diagnostic method for dumping the tracker contents to "stdout"voidremove all additional properties to clear out the torrentvoidvoidprotected boolean[]restoreState(boolean do_pieces, boolean do_fluff) monitor must be held before calling meselectHybridHashType(int type) voidserialiseToBEncodedFile(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 elsewherevoidserialiseToXMLFile(File target_file) This method will serialise a torrent using an XML encoding to a filevoidsetAdditionalByteArrayProperty(String name, byte[] value) voidsetAdditionalListProperty(String name, List value) voidsetAdditionalLongProperty(String name, Long value) voidsetAdditionalMapProperty(String name, Map value) voidsetAdditionalProperty(String name, Object value) set an arbitrary property.voidsetAdditionalStringProperty(String name, String value) The additional properties are used for holding non-core data for Azureus' own userbooleansetAnnounceURL(URL url) voidsetComment(String comment) voidsetCreatedBy(byte[] cb) voidsetCreationDate(long date) voidsetDiscardFluff(boolean discard) voidsetHashOverride(byte[] hash) voidsetPieces(byte[][] pieces) This method exists to support the temporary discarding of piece hashes to conserver memory.voidsetPrivate(boolean _private) Note - changing the private attribute CHANGES THE TORRENT HASHsetSimpleTorrentDisabled(boolean disabled) voidNote - changing the source CHANGES THE TORRENT HASHbooleanupdateExportability(TOTorrent from) Propagate exportability from another torrent to this one - has to have same hash.Methods inherited from class LogRelation
propogatedRelationText, queryForClassMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface 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:
setDiscardFluffin interfaceTorrentUtils.ExtendedTorrent
-
getName
-
getTorrentType
public int getTorrentType()- Specified by:
getTorrentTypein interfaceTOTorrent- Returns:
- One of the TT_ constants
-
isExportable
public boolean isExportable()Description copied from interface:TOTorrentIs the torrent in a fit state to export and share?- Specified by:
isExportablein interfaceTOTorrent- Returns:
-
updateExportability
Description copied from interface:TOTorrentPropagate 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:
updateExportabilityin interfaceTOTorrent- Parameters:
from-- Returns:
-
isSimpleTorrent
public boolean isSimpleTorrent()Description copied from interface:TOTorrentA "simple torrent" is one that consists of a single file on its own (i.e. not in a nested directory).- Specified by:
isSimpleTorrentin interfaceTOTorrent- Returns:
-
getComment
public byte[] getComment()Description copied from interface:TOTorrentComment is an optional torrent property- Specified by:
getCommentin interfaceTOTorrent- Returns:
-
setComment
- Specified by:
setCommentin interfaceTOTorrent
-
getCreationDate
public long getCreationDate()Description copied from interface:TOTorrentGets the creation date of the torrent. Optional property, 0 returned if not set- Specified by:
getCreationDatein interfaceTOTorrent- Returns:
-
setCreationDate
public void setCreationDate(long date) - Specified by:
setCreationDatein interfaceTOTorrent
-
getCreatedBy
public byte[] getCreatedBy()- Specified by:
getCreatedByin interfaceTOTorrent
-
setCreatedBy
public void setCreatedBy(byte[] cb) - Specified by:
setCreatedByin interfaceTOTorrent
-
isDecentralised
public boolean isDecentralised()- Specified by:
isDecentralisedin interfaceTOTorrent
-
getAnnounceURL
Description copied from interface:TOTorrentA 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:
getAnnounceURLin interfaceTOTorrent- Returns:
-
getAnnounceURLGroup
Description copied from interface:TOTorrentWhen a group of sets of trackers is defined their URLs are accessed via this method- Specified by:
getAnnounceURLGroupin interfaceTOTorrent- Returns:
- the group, always present, which may have 0 members
-
getAnnounceURLSupport
-
setAnnounceURL
- Specified by:
setAnnounceURLin interfaceTOTorrent- Parameters:
url-- Returns:
- true-changed; false-not changed
-
getAnnounceURLGroupSupport
-
discardPieces
protected void discardPieces(long now, boolean force) -
getPieces
Description copied from interface:TOTorrentThis method provides access to the SHA1/SHA256 hash values (20/32 bytes each) that correspond to the pieces of the torrent.- Specified by:
getPiecesin 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:
peekPiecesin interfaceTorrentUtils.ExtendedTorrent- Returns:
- Throws:
TOTorrentException
-
setPieces
Description copied from interface:TOTorrentThis method exists to support the temporary discarding of piece hashes to conserver memory. It should only be used with care!- Specified by:
setPiecesin interfaceTOTorrent- Parameters:
pieces-- Throws:
TOTorrentException
-
getPieceLength
public long getPieceLength()Description copied from interface:TOTorrentReturns the piece length used for the torrent- Specified by:
getPieceLengthin interfaceTOTorrent- Returns:
-
getNumberOfPieces
public int getNumberOfPieces()- Specified by:
getNumberOfPiecesin interfaceTOTorrent
-
getSize
-
getFileCount
public int getFileCount()- Specified by:
getFileCountin interfaceTOTorrent
-
getFiles
Description copied from interface:TOTorrentA torrent consists of one or more files. These are accessed via this method. -
getHash
Description copied from interface:TOTorrentFor a V1 or hybrid torrent this returns the SHA1 hash For a V2 only torrent it returns the truncated SHA256 hash- Specified by:
getHashin interfaceTOTorrent- Returns:
- Throws:
TOTorrentException
-
getFullHash
- Specified by:
getFullHashin interfaceTOTorrent- Returns:
- SHA1 hash for v1/hybrid torrents, SHA256 hash for hybrid/v2 torrents
- Throws:
TOTorrentException
-
getHashWrapper
Description copied from interface:TOTorrentconvenience method to get a wrapped hash for performance purposes- Specified by:
getHashWrapperin interfaceTOTorrent- Returns:
- Throws:
TOTorrentException
-
selectHybridHashType
- Specified by:
selectHybridHashTypein interfaceTOTorrent- Throws:
TOTorrentException
-
setHashOverride
- Specified by:
setHashOverridein interfaceTOTorrent- Throws:
TOTorrentException
-
setSimpleTorrentDisabled
- Specified by:
setSimpleTorrentDisabledin interfaceTOTorrent- Throws:
TOTorrentException
-
isSimpleTorrentDisabled
- Specified by:
isSimpleTorrentDisabledin interfaceTOTorrent- Throws:
TOTorrentException
-
getPrivate
public boolean getPrivate()- Specified by:
getPrivatein interfaceTOTorrent
-
setPrivate
Description copied from interface:TOTorrentNote - changing the private attribute CHANGES THE TORRENT HASH- Specified by:
setPrivatein interfaceTOTorrent- Parameters:
_private-- Throws:
TOTorrentException
-
getSource
-
setSource
Description copied from interface:TOTorrentNote - changing the source CHANGES THE TORRENT HASH- Specified by:
setSourcein interfaceTOTorrent- Parameters:
str-- Throws:
TOTorrentException
-
hasSameHashAs
Description copied from interface:TOTorrentcompares two torrents by hash- Specified by:
hasSameHashAsin interfaceTOTorrent- Parameters:
other-- Returns:
-
setAdditionalStringProperty
Description copied from interface:TOTorrentThe additional properties are used for holding non-core data for Azureus' own user- Specified by:
setAdditionalStringPropertyin interfaceTOTorrent- Parameters:
name- name of the property (e.g. "encoding")value- value. This will be encoded with default encoding
-
getAdditionalStringProperty
- Specified by:
getAdditionalStringPropertyin interfaceTOTorrent
-
setAdditionalByteArrayProperty
- Specified by:
setAdditionalByteArrayPropertyin interfaceTOTorrent
-
getAdditionalByteArrayProperty
- Specified by:
getAdditionalByteArrayPropertyin interfaceTOTorrent
-
setAdditionalLongProperty
- Specified by:
setAdditionalLongPropertyin interfaceTOTorrent
-
getAdditionalLongProperty
- Specified by:
getAdditionalLongPropertyin interfaceTOTorrent
-
setAdditionalListProperty
- Specified by:
setAdditionalListPropertyin interfaceTOTorrent
-
getAdditionalListProperty
- Specified by:
getAdditionalListPropertyin interfaceTOTorrent
-
setAdditionalMapProperty
- Specified by:
setAdditionalMapPropertyin interfaceTOTorrent
-
getAdditionalMapProperty
- Specified by:
getAdditionalMapPropertyin interfaceTOTorrent
-
getAdditionalProperty
- Specified by:
getAdditionalPropertyin interfaceTOTorrent
-
setAdditionalProperty
Description copied from interface:TOTorrentset an arbitrary property. Make sure its compatible with bencoding!- Specified by:
setAdditionalPropertyin interfaceTOTorrent
-
removeAdditionalProperty
- Specified by:
removeAdditionalPropertyin interfaceTOTorrent
-
removeAdditionalProperties
public void removeAdditionalProperties()Description copied from interface:TOTorrentremove all additional properties to clear out the torrent- Specified by:
removeAdditionalPropertiesin interfaceTOTorrent
-
serialiseToBEncodedFile
Description copied from interface:TOTorrentThis method will serialise a torrent using the standard "b-encoding" mechanism into a file- Specified by:
serialiseToBEncodedFilein interfaceTOTorrent- Parameters:
target_file-- Throws:
TOTorrentException
-
serialiseToMap
Description copied from interface:TOTorrentThis method will serialise a torrent into a Map consistent with that used by the "b-encoding" routines defined elsewhere- Specified by:
serialiseToMapin interfaceTOTorrent- Returns:
- Throws:
TOTorrentException
-
serialiseToXMLFile
Description copied from interface:TOTorrentThis method will serialise a torrent using an XML encoding to a file- Specified by:
serialiseToXMLFilein interfaceTOTorrent- Parameters:
target_file-- Throws:
TOTorrentException
-
addListener
- Specified by:
addListenerin interfaceTOTorrent
-
removeListener
- Specified by:
removeListenerin interfaceTOTorrent
-
getMonitor
- Specified by:
getMonitorin interfaceTOTorrent
-
print
-
getRelationText
Description copied from class:LogRelationA short description of what your class holds that can be printed by the logger- Overrides:
getRelationTextin classLogRelation- Returns:
-
getQueryableInterfaces
Description copied from class:LogRelationQuery this class for a reference to another class that it may hold- Overrides:
getQueryableInterfacesin classLogRelation- Returns:
- If found, the class desired. Otherwise, null.
-
getUTF8Name
Description copied from interface:TOTorrentRetrieves 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:
getUTF8Namein interfaceTOTorrent
-