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 Mapprivate Mapprivate final TOTorrentAnnounceURLGroupImplprivate URLprivate byte[]private booleanprivate booleanprivate byte[]private longprivate TOTorrentFileImpl[]private booleanprivate static CopyOnWriteList<TOTorrentListener> private List<TOTorrentListener> private intprivate longprivate byte[][]private booleanprivate booleanprivate booleanprotected final AEMonitorprotected static final Listprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprivate byte[]private byte[]private byte[]private byte[]private HashWrapperprivate HashWrapperprivate HashWrapperprivate byte[]private Stringprivate 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
ConstructorsModifierConstructorDescriptionprotectedConstructor for deserialisationprotectedTOTorrentImpl(String _torrent_name, URL _announce_url, boolean _simple_torrent) Constructor for creation -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddAdditionalInfoProperty(String name, Object value) protected voidaddAdditionalProperty(String name, Object value) static voidaddGlobalListener(TOTorrentListener listener) voidprotected voidaddTorrentAnnounceURLSet(URL[] urls) protected voidfireChanged(int type, Object data) protected voidbyte[]protected Mapprotected MapgetAdditionalProperty(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 hashprotected byte[]convenience 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 loggerprotected booleanlonggetSize()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.booleanvoidprint()A diagnostic method for dumping the tracker contents to "stdout"protected StringreadStringFromMetaData(byte[] value) protected StringreadStringFromMetaData(Map meta_data, String name) voidremove all additional properties to clear out the torrentvoidstatic voidremoveGlobalListener(TOTorrentListener listener) voidselectHybridHashType(int type) voidserialiseToBEncodedFile(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 elsewherevoidserialiseToXMLFile(File 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) protected voidsetComment(byte[] _comment) voidsetComment(String _comment) protected voidvoidsetCreatedBy(byte[] _created_by) protected voidsetCreatedBy(String _created_by) voidsetCreationDate(long _creation_date) protected voidsetFiles(TOTorrentFileImpl[] _files) protected voidsetHashFromInfo(Map<String, Object> info) voidsetHashOverride(byte[] hash) protected voidsetName(byte[] _name) protected voidsetNameUTF8(byte[] name) protected voidsetPiece(int index, byte[] piece) protected voidsetPieceLength(long _length) voidsetPieces(byte[][] _pieces) This method exists to support the temporary discarding of piece hashes to conserver memory.voidsetPrivate(boolean _private_torrent) Note - changing the private attribute CHANGES THE TORRENT HASHprotected voidsetSimpleTorrent(boolean _simple_torrent) setSimpleTorrentDisabled(boolean disabled) protected voidsetSimpleTorrentDisabledInternal(boolean b) voidNote - changing the source CHANGES THE TORRENT HASHprotected voidsetTorrentType(int type) booleanupdateExportability(TOTorrent from) Propagate exportability from another torrent to this one - has to have same hash.protected byte[]writeStringToMetaData(String value) protected voidwriteStringToMetaData(Map meta_data, String name, String value) 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
-
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
-
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
-
-
Method Details
-
addGlobalListener
-
removeGlobalListener
-
setConstructed
- Throws:
TOTorrentException
-
fixupRootHashes
protected void fixupRootHashes() -
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:
output_file-- Throws:
TOTorrentException
-
serialiseToByteArray
- 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:
file-- Throws:
TOTorrentException
-
getTorrentType
public int getTorrentType()- Specified by:
getTorrentTypein interfaceTOTorrent- Returns:
- One of the TT_ constants
-
setTorrentType
protected void setTorrentType(int type) -
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:
-
getName
-
setName
protected void setName(byte[] _name) -
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
-
setNameUTF8
protected void setNameUTF8(byte[] name) -
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
protected void setComment(byte[] _comment) -
setComment
- Specified by:
setCommentin 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:
-
setAnnounceURL
- Specified by:
setAnnounceURLin interfaceTOTorrent- Parameters:
url-- Returns:
- true-changed; false-not changed
-
isDecentralised
public boolean isDecentralised()- Specified by:
isDecentralisedin 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 _creation_date) - Specified by:
setCreationDatein interfaceTOTorrent
-
setCreatedBy
public void setCreatedBy(byte[] _created_by) - Specified by:
setCreatedByin interfaceTOTorrent
-
setCreatedBy
-
getCreatedBy
public byte[] getCreatedBy()- Specified by:
getCreatedByin interfaceTOTorrent
-
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
-
hasSameHashAs
Description copied from interface:TOTorrentcompares two torrents by hash- Specified by:
hasSameHashAsin interfaceTOTorrent- Parameters:
other-- Returns:
-
setHashFromInfo
- Throws:
TOTorrentException
-
selectHybridHashType
- Specified by:
selectHybridHashTypein interfaceTOTorrent- Throws:
TOTorrentException
-
setHashOverride
- Specified by:
setHashOverridein interfaceTOTorrent- Throws:
TOTorrentException
-
getHashOverride
protected byte[] getHashOverride() -
setSimpleTorrentDisabled
- Specified by:
setSimpleTorrentDisabledin interfaceTOTorrent- Throws:
TOTorrentException
-
isSimpleTorrentDisabled
- Specified by:
isSimpleTorrentDisabledin interfaceTOTorrent- Throws:
TOTorrentException
-
setSimpleTorrentDisabledInternal
protected void setSimpleTorrentDisabledInternal(boolean b) -
setPrivate
Description copied from interface:TOTorrentNote - changing the private attribute CHANGES THE TORRENT HASH- Specified by:
setPrivatein interfaceTOTorrent- Parameters:
_private_torrent-- Throws:
TOTorrentException
-
getPrivate
public boolean getPrivate()- Specified by:
getPrivatein interfaceTOTorrent
-
setSource
Description copied from interface:TOTorrentNote - changing the source CHANGES THE TORRENT HASH- Specified by:
setSourcein interfaceTOTorrent- Parameters:
str-- Throws:
TOTorrentException
-
getSource
-
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
-
addTorrentAnnounceURLSet
-
getSize
-
getPieceLength
public long getPieceLength()Description copied from interface:TOTorrentReturns the piece length used for the torrent- Specified by:
getPieceLengthin interfaceTOTorrent- Returns:
-
setPieceLength
protected void setPieceLength(long _length) -
getNumberOfPieces
public int getNumberOfPieces()- Specified by:
getNumberOfPiecesin interfaceTOTorrent
-
getPieces
-
setPieces
-
setPiece
protected void setPiece(int index, byte[] piece) -
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. -
setFiles
-
getSimpleTorrent
protected boolean getSimpleTorrent() -
setSimpleTorrent
protected void setSimpleTorrent(boolean _simple_torrent) -
getAdditionalProperties
-
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
-
setAdditionalProperty
Description copied from interface:TOTorrentset an arbitrary property. Make sure its compatible with bencoding!- Specified by:
setAdditionalPropertyin 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
-
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
-
addAdditionalProperty
-
addAdditionalInfoProperty
-
getAdditionalInfoProperties
-
readStringFromMetaData
-
readStringFromMetaData
-
writeStringToMetaData
-
writeStringToMetaData
-
print
-
fireChanged
-
addListener
- Specified by:
addListenerin interfaceTOTorrent
-
removeListener
- Specified by:
removeListenerin interfaceTOTorrent
-
getMonitor
- Specified by:
getMonitorin interfaceTOTorrent
-
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.
-