Package com.biglybt.core.download.impl
Class DownloadManagerStateImpl.CachedStateWrapper
java.lang.Object
com.biglybt.core.logging.LogRelation
com.biglybt.core.download.impl.DownloadManagerStateImpl.CachedStateWrapper
- All Implemented Interfaces:
TOTorrent
,TorrentUtils.ExtendedTorrent
- Enclosing class:
DownloadManagerStateImpl
protected static class DownloadManagerStateImpl.CachedStateWrapper
extends LogRelation
implements TorrentUtils.ExtendedTorrent
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected class
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) DownloadManagerStateImpl.CachedStateWrapper.cacheGroup
(package private) URL
(package private) Map
(package private) Map
(package private) Map
(package private) Map
(package private) TorrentUtils.ExtendedTorrent
(package private) boolean
(package private) boolean
(package private) final DownloadManagerImpl
(package private) int
(package private) TOTorrentException
(package private) Boolean
(package private) boolean
(package private) List
<TOTorrentListener> (package private) Boolean
(package private) long
(package private) final String
(package private) HashWrapper
(package private) Integer
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
ConstructorsModifierConstructorDescriptionprotected
CachedStateWrapper
(DownloadManagerImpl _download_manager, String _torrent_file, byte[] _torrent_hash, Map _cache, boolean _force_piece_discard) -
Method Summary
Modifier and TypeMethodDescriptionvoid
protected void
protected static Map
protected static List
protected boolean
fixup()
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 hashimportGroup
(List l) boolean
boolean
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
protected TorrentUtils.ExtendedTorrent
byte[][]
void
print()
A diagnostic method for dumping the tracker contents to "stdout"void
remove all additional properties to clear out the torrentvoid
void
selectHybridHashType
(int type) void
serialiseToBEncodedFile
(File 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 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
-
download_manager
-
torrent_file
-
torrent_hash_wrapper
HashWrapper torrent_hash_wrapper -
cache
Map cache -
cache_attributes
Map cache_attributes -
cache_azp
Map cache_azp -
cache_azpp
Map cache_azpp -
delegate
-
fixup_failure
TOTorrentException fixup_failure -
discard_pieces
boolean discard_pieces -
logged_failure
boolean logged_failure -
torrent_type
Integer torrent_type -
simple_torrent
Boolean simple_torrent -
size
long size -
is_private
Boolean is_private -
file_count
int file_count -
announce_url
URL announce_url -
announce_group
DownloadManagerStateImpl.CachedStateWrapper.cacheGroup announce_group -
pending_listeners
List<TOTorrentListener> pending_listeners -
discard_fluff
volatile boolean discard_fluff
-
-
Constructor Details
-
CachedStateWrapper
protected CachedStateWrapper(DownloadManagerImpl _download_manager, String _torrent_file, byte[] _torrent_hash, Map _cache, boolean _force_piece_discard)
-
-
Method Details
-
export
- Throws:
TOTorrentException
-
exportGroup
-
importGroup
protected DownloadManagerStateImpl.CachedStateWrapper.cacheGroup importGroup(List l) throws Exception - Throws:
Exception
-
clearCache
protected void clearCache() -
fixup
protected boolean fixup() -
loadRealState
- Throws:
TOTorrentException
-
getName
public byte[] getName()Description copied from interface:TOTorrent
Get the name of the torrent -
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
-
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
-
isCreated
public boolean isCreated() -
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:
-
setAnnounceURL
- Specified by:
setAnnounceURL
in interfaceTOTorrent
- Parameters:
url
-- Returns:
- true-changed; false-not changed
-
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
-
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
-
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
-
peekPieces
- Specified by:
peekPieces
in interfaceTorrentUtils.ExtendedTorrent
- Throws:
TOTorrentException
-
setDiscardFluff
public void setDiscardFluff(boolean discard) - Specified by:
setDiscardFluff
in interfaceTorrentUtils.ExtendedTorrent
-
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
-
hasSameHashAs
Description copied from interface:TOTorrent
compares two torrents by hash- Specified by:
hasSameHashAs
in interfaceTOTorrent
- Parameters:
other
-- Returns:
-
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
-
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:
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:
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.
-