Package com.biglybt.core.torrent.impl
Class TOTorrentImpl
java.lang.Object
com.biglybt.core.logging.LogRelation
com.biglybt.core.torrent.impl.TOTorrentImpl
- All Implemented Interfaces:
TOTorrent
- Direct Known Subclasses:
TOTorrentCreateImpl
,TOTorrentDeserialiseImpl
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Map
private Map
private final TOTorrentAnnounceURLGroupImpl
private URL
private byte[]
private boolean
private boolean
private byte[]
private long
private TOTorrentFileImpl[]
private boolean
private static CopyOnWriteList
<TOTorrentListener> private List
<TOTorrentListener> private int
private long
private byte[][]
private boolean
private boolean
private boolean
protected final AEMonitor
protected static final List
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
private byte[]
private byte[]
private byte[]
private byte[]
private HashWrapper
private HashWrapper
private HashWrapper
private byte[]
private byte[]
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
ConstructorsModifierConstructorDescriptionprotected
Constructor for deserialisationprotected
TOTorrentImpl
(String _torrent_name, URL _announce_url, boolean _simple_torrent) Constructor for creation -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addAdditionalInfoProperty
(String name, Object value) protected void
addAdditionalProperty
(String name, Object value) static void
addGlobalListener
(TOTorrentListener listener) void
protected void
addTorrentAnnounceURLSet
(URL[] urls) protected URL
anonymityTransform
(URL url) protected void
fireChanged
(int type, Object data) protected void
byte[]
protected Map
protected Map
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 hashprotected byte[]
convenience 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 loggerprotected boolean
long
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
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
void
print()
A diagnostic method for dumping the tracker contents to "stdout"protected String
readStringFromMetaData
(byte[] value) protected String
readStringFromMetaData
(Map meta_data, String name) void
remove all additional properties to clear out the torrentvoid
static void
removeGlobalListener
(TOTorrentListener listener) void
selectHybridHashType
(int type) void
serialiseToBEncodedFile
(File output_file) This method will serialise a torrent using the standard "b-encoding" mechanism into a fileprotected byte[]
This 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) protected void
setComment
(byte[] _comment) void
setComment
(String _comment) protected void
void
setCreatedBy
(byte[] _created_by) protected void
setCreatedBy
(String _created_by) void
setCreationDate
(long _creation_date) protected void
setFiles
(TOTorrentFileImpl[] _files) protected void
setHashFromInfo
(Map<String, Object> info) void
setHashOverride
(byte[] hash) protected void
setName
(byte[] _name) protected void
setNameUTF8
(byte[] _name) protected void
setPiece
(int index, byte[] piece) protected void
setPieceLength
(long _length) void
setPieces
(byte[][] _pieces) This method exists to support the temporary discarding of piece hashes to conserver memory.void
setPrivate
(boolean _private_torrent) Note - changing the private attribute CHANGES THE TORRENT HASHprotected void
setSimpleTorrent
(boolean _simple_torrent) setSimpleTorrentDisabled
(boolean disabled) protected void
setSimpleTorrentDisabledInternal
(boolean b) void
Note - changing the source CHANGES THE TORRENT HASHprotected void
setTorrentType
(int type) boolean
updateExportability
(TOTorrent from) Propagate exportability from another torrent to this one - has to have same hash.protected byte[]
writeStringToMetaData
(String value) protected void
writeStringToMetaData
(Map meta_data, String name, String value) 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
-
TK_ANNOUNCE
- See Also:
-
TK_ANNOUNCE_LIST
- See Also:
-
TK_COMMENT
- See Also:
-
TK_CREATION_DATE
- See Also:
-
TK_CREATED_BY
- See Also:
-
TK_INFO
- See Also:
-
TK_NAME
- See Also:
-
TK_LENGTH
- See Also:
-
TK_PATH
- See Also:
-
TK_FILES
- See Also:
-
TK_PIECE_LENGTH
- See Also:
-
TK_PIECES
- See Also:
-
TK_PRIVATE
- See Also:
-
TK_SOURCE
- See Also:
-
TK_NAME_UTF8
- See Also:
-
TK_PATH_UTF8
- See Also:
-
TK_COMMENT_UTF8
- See Also:
-
TK_WEBSEED_BT
- See Also:
-
TK_WEBSEED_GR
- See Also:
-
TK_HASH_OVERRIDE
- See Also:
-
TK_ENCODING
- See Also:
-
TK_ADDITIONAL_OK_ATTRS
-
TK_BEP47_ATTRS
- See Also:
-
TK_V2_META_VERSION
- See Also:
-
TK_V2_FILE_TREE
- See Also:
-
TK_V2_PIECE_LAYERS
- See Also:
-
TK_V2_PIECES_ROOT
- See Also:
-
global_listeners
-
torrent_type
private int torrent_type -
torrent_name
private byte[] torrent_name -
torrent_name_utf8
private byte[] torrent_name_utf8 -
comment
private byte[] comment -
announce_url
-
announce_group
-
piece_length
private long piece_length -
pieces
private byte[][] pieces -
number_of_pieces
private int number_of_pieces -
torrent_hash_override
private byte[] torrent_hash_override -
torrent_hash
private byte[] torrent_hash -
torrent_hash_wrapper
-
torrent_hash_v1
private byte[] torrent_hash_v1 -
torrent_hash_wrapper_v1
-
torrent_hash_v2
private byte[] torrent_hash_v2 -
torrent_hash_wrapper_v2
-
simple_torrent_original
private boolean simple_torrent_original -
simple_torrent_effective
private boolean simple_torrent_effective -
files
-
creation_date
private long creation_date -
created_by
private byte[] created_by -
additional_properties
-
additional_info_properties
-
created
private boolean created -
serialising
private boolean serialising -
listeners
-
this_mon
-
constructing
private boolean constructing -
fixed_up_root_hashes
private boolean fixed_up_root_hashes
-
-
Constructor Details
-
TOTorrentImpl
protected TOTorrentImpl()Constructor for deserialisation -
TOTorrentImpl
Constructor for creation
-
-
Method Details
-
addGlobalListener
-
removeGlobalListener
-
setConstructed
- Throws:
TOTorrentException
-
fixupRootHashes
protected void fixupRootHashes() -
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:
output_file
-- Throws:
TOTorrentException
-
serialiseToByteArray
- 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
-
getTorrentType
public int getTorrentType()- Specified by:
getTorrentType
in interfaceTOTorrent
- Returns:
- One of the TT_ constants
-
setTorrentType
protected void setTorrentType(int type) -
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:
-
getName
public byte[] getName()Description copied from interface:TOTorrent
Get the name of the torrent -
setName
protected void setName(byte[] _name) -
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
-
setNameUTF8
protected void setNameUTF8(byte[] _name) -
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
protected void setComment(byte[] _comment) -
setComment
- Specified by:
setComment
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
-
isDecentralised
public boolean isDecentralised()- Specified by:
isDecentralised
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 _creation_date) - Specified by:
setCreationDate
in interfaceTOTorrent
-
setCreatedBy
public void setCreatedBy(byte[] _created_by) - Specified by:
setCreatedBy
in interfaceTOTorrent
-
setCreatedBy
-
getCreatedBy
public byte[] getCreatedBy()- Specified by:
getCreatedBy
in interfaceTOTorrent
-
isCreated
public boolean isCreated() -
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
-
hasSameHashAs
Description copied from interface:TOTorrent
compares two torrents by hash- Specified by:
hasSameHashAs
in interfaceTOTorrent
- Parameters:
other
-- Returns:
-
setHashFromInfo
- Throws:
TOTorrentException
-
selectHybridHashType
- Specified by:
selectHybridHashType
in interfaceTOTorrent
- Throws:
TOTorrentException
-
setHashOverride
- Specified by:
setHashOverride
in interfaceTOTorrent
- Throws:
TOTorrentException
-
getHashOverride
protected byte[] getHashOverride() -
setSimpleTorrentDisabled
- Specified by:
setSimpleTorrentDisabled
in interfaceTOTorrent
- Throws:
TOTorrentException
-
isSimpleTorrentDisabled
- Specified by:
isSimpleTorrentDisabled
in interfaceTOTorrent
- Throws:
TOTorrentException
-
setSimpleTorrentDisabledInternal
protected void setSimpleTorrentDisabledInternal(boolean b) -
setPrivate
Description copied from interface:TOTorrent
Note - changing the private attribute CHANGES THE TORRENT HASH- Specified by:
setPrivate
in interfaceTOTorrent
- Parameters:
_private_torrent
-- Throws:
TOTorrentException
-
getPrivate
public boolean getPrivate()- Specified by:
getPrivate
in interfaceTOTorrent
-
setSource
Description copied from interface:TOTorrent
Note - changing the source CHANGES THE TORRENT HASH- Specified by:
setSource
in interfaceTOTorrent
- Parameters:
str
-- Throws:
TOTorrentException
-
getSource
-
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
-
getSize
public long getSize() -
getPieceLength
public long getPieceLength()Description copied from interface:TOTorrent
Returns the piece length used for the torrent- Specified by:
getPieceLength
in interfaceTOTorrent
- Returns:
-
setPieceLength
protected void setPieceLength(long _length) -
getNumberOfPieces
public int getNumberOfPieces()- Specified by:
getNumberOfPieces
in interfaceTOTorrent
-
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[][] _pieces) 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! -
setPiece
protected void setPiece(int index, byte[] piece) -
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. -
setFiles
-
getSimpleTorrent
protected boolean getSimpleTorrent() -
setSimpleTorrent
protected void setSimpleTorrent(boolean _simple_torrent) -
getAdditionalProperties
-
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
-
setAdditionalProperty
Description copied from interface:TOTorrent
set an arbitrary property. Make sure its compatible with bencoding!- Specified by:
setAdditionalProperty
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
-
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
-
addAdditionalProperty
-
addAdditionalInfoProperty
-
getAdditionalInfoProperties
-
readStringFromMetaData
-
readStringFromMetaData
-
writeStringToMetaData
-
writeStringToMetaData
-
anonymityTransform
-
print
public void print()Description copied from interface:TOTorrent
A diagnostic method for dumping the tracker contents to "stdout" -
fireChanged
-
addListener
- Specified by:
addListener
in interfaceTOTorrent
-
removeListener
- Specified by:
removeListener
in interfaceTOTorrent
-
getMonitor
- Specified by:
getMonitor
in interfaceTOTorrent
-
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.
-