Class TOTorrentImpl

    • Field Detail

      • TK_ANNOUNCE_LIST

        protected static final java.lang.String TK_ANNOUNCE_LIST
        See Also:
        Constant Field Values
      • TK_CREATION_DATE

        protected static final java.lang.String TK_CREATION_DATE
        See Also:
        Constant Field Values
      • TK_PIECE_LENGTH

        protected static final java.lang.String TK_PIECE_LENGTH
        See Also:
        Constant Field Values
      • TK_COMMENT_UTF8

        protected static final java.lang.String TK_COMMENT_UTF8
        See Also:
        Constant Field Values
      • TK_HASH_OVERRIDE

        protected static final java.lang.String TK_HASH_OVERRIDE
        See Also:
        Constant Field Values
      • TK_ADDITIONAL_OK_ATTRS

        protected static final java.util.List TK_ADDITIONAL_OK_ATTRS
      • TK_V2_META_VERSION

        protected static final java.lang.String TK_V2_META_VERSION
        See Also:
        Constant Field Values
      • TK_V2_FILE_TREE

        protected static final java.lang.String TK_V2_FILE_TREE
        See Also:
        Constant Field Values
      • TK_V2_PIECE_LAYERS

        protected static final java.lang.String TK_V2_PIECE_LAYERS
        See Also:
        Constant Field Values
      • TK_V2_PIECES_ROOT

        protected static final java.lang.String TK_V2_PIECES_ROOT
        See Also:
        Constant Field Values
      • 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

        private java.net.URL announce_url
      • 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

        private HashWrapper torrent_hash_wrapper
      • torrent_hash_v1

        private byte[] torrent_hash_v1
      • torrent_hash_wrapper_v1

        private HashWrapper torrent_hash_wrapper_v1
      • torrent_hash_v2

        private byte[] torrent_hash_v2
      • torrent_hash_wrapper_v2

        private HashWrapper torrent_hash_wrapper_v2
      • simple_torrent

        private boolean simple_torrent
      • creation_date

        private long creation_date
      • created_by

        private byte[] created_by
      • additional_properties

        private java.util.Map additional_properties
      • additional_info_properties

        private final java.util.Map additional_info_properties
      • created

        private boolean created
      • serialising

        private boolean serialising
      • this_mon

        protected final AEMonitor this_mon
      • constructing

        private boolean constructing
      • fixed_up_root_hashes

        private boolean fixed_up_root_hashes
    • Constructor Detail

      • TOTorrentImpl

        protected TOTorrentImpl()
        Constructor for deserialisation
      • TOTorrentImpl

        protected TOTorrentImpl​(java.lang.String _torrent_name,
                                java.net.URL _announce_url,
                                boolean _simple_torrent)
        Constructor for creation
    • Method Detail

      • addGlobalListener

        public static void addGlobalListener​(TOTorrentListener listener)
      • removeGlobalListener

        public static void removeGlobalListener​(TOTorrentListener listener)
      • fixupRootHashes

        protected void fixupRootHashes()
      • getTorrentType

        public int getTorrentType()
        Specified by:
        getTorrentType in interface TOTorrent
        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 interface TOTorrent
        Returns:
      • updateExportability

        public boolean updateExportability​(TOTorrent from)
        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 interface TOTorrent
        Returns:
      • getName

        public byte[] getName()
        Description copied from interface: TOTorrent
        Get the name of the torrent
        Specified by:
        getName in interface TOTorrent
        Returns:
      • setName

        protected void setName​(byte[] _name)
      • getUTF8Name

        public java.lang.String 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 interface TOTorrent
      • 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 interface TOTorrent
        Returns:
      • getComment

        public byte[] getComment()
        Description copied from interface: TOTorrent
        Comment is an optional torrent property
        Specified by:
        getComment in interface TOTorrent
        Returns:
      • setComment

        protected void setComment​(byte[] _comment)
      • setComment

        public void setComment​(java.lang.String _comment)
        Specified by:
        setComment in interface TOTorrent
      • getAnnounceURL

        public java.net.URL 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 interface TOTorrent
        Returns:
      • setAnnounceURL

        public boolean setAnnounceURL​(java.net.URL url)
        Specified by:
        setAnnounceURL in interface TOTorrent
        Returns:
        true-changed; false-not changed
      • 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 interface TOTorrent
        Returns:
      • setCreationDate

        public void setCreationDate​(long _creation_date)
        Specified by:
        setCreationDate in interface TOTorrent
      • setCreatedBy

        public void setCreatedBy​(byte[] _created_by)
        Specified by:
        setCreatedBy in interface TOTorrent
      • setCreatedBy

        protected void setCreatedBy​(java.lang.String _created_by)
      • hasSameHashAs

        public boolean hasSameHashAs​(TOTorrent other)
        Description copied from interface: TOTorrent
        compares two torrents by hash
        Specified by:
        hasSameHashAs in interface TOTorrent
        Returns:
      • getHashOverride

        protected byte[] getHashOverride()
      • getSource

        public java.lang.String getSource()
        Specified by:
        getSource in interface TOTorrent
      • getAnnounceURLGroup

        public TOTorrentAnnounceURLGroup 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 interface TOTorrent
        Returns:
        the group, always present, which may have 0 members
      • addTorrentAnnounceURLSet

        protected void addTorrentAnnounceURLSet​(java.net.URL[] urls)
      • getSize

        public long getSize()
        Specified by:
        getSize in interface TOTorrent
      • getPieceLength

        public long getPieceLength()
        Description copied from interface: TOTorrent
        Returns the piece length used for the torrent
        Specified by:
        getPieceLength in interface TOTorrent
        Returns:
      • setPieceLength

        protected void setPieceLength​(long _length)
      • 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.
        Specified by:
        getPieces in interface TOTorrent
        Returns:
      • 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!
        Specified by:
        setPieces in interface TOTorrent
      • setPiece

        protected void setPiece​(int index,
                                byte[] piece)
      • getFiles

        public TOTorrentFileImpl[] getFiles()
        Description copied from interface: TOTorrent
        A torrent consists of one or more files. These are accessed via this method.
        Specified by:
        getFiles in interface TOTorrent
        Returns:
      • getSimpleTorrent

        protected boolean getSimpleTorrent()
      • setSimpleTorrent

        protected void setSimpleTorrent​(boolean _simple_torrent)
      • getAdditionalProperties

        protected java.util.Map getAdditionalProperties()
      • setAdditionalStringProperty

        public void setAdditionalStringProperty​(java.lang.String name,
                                                java.lang.String value)
        Description copied from interface: TOTorrent
        The additional properties are used for holding non-core data for Azureus' own user
        Specified by:
        setAdditionalStringProperty in interface TOTorrent
        Parameters:
        name - name of the property (e.g. "encoding")
        value - value. This will be encoded with default encoding
      • setAdditionalProperty

        public void setAdditionalProperty​(java.lang.String name,
                                          java.lang.Object value)
        Description copied from interface: TOTorrent
        set an arbitrary property. Make sure its compatible with bencoding!
        Specified by:
        setAdditionalProperty in interface TOTorrent
      • setAdditionalLongProperty

        public void setAdditionalLongProperty​(java.lang.String name,
                                              java.lang.Long value)
        Specified by:
        setAdditionalLongProperty in interface TOTorrent
      • setAdditionalListProperty

        public void setAdditionalListProperty​(java.lang.String name,
                                              java.util.List value)
        Specified by:
        setAdditionalListProperty in interface TOTorrent
      • setAdditionalMapProperty

        public void setAdditionalMapProperty​(java.lang.String name,
                                             java.util.Map value)
        Specified by:
        setAdditionalMapProperty in interface TOTorrent
      • getAdditionalMapProperty

        public java.util.Map getAdditionalMapProperty​(java.lang.String name)
        Specified by:
        getAdditionalMapProperty in interface TOTorrent
      • getAdditionalProperty

        public java.lang.Object getAdditionalProperty​(java.lang.String name)
        Specified by:
        getAdditionalProperty in interface TOTorrent
      • removeAdditionalProperties

        public void removeAdditionalProperties()
        Description copied from interface: TOTorrent
        remove all additional properties to clear out the torrent
        Specified by:
        removeAdditionalProperties in interface TOTorrent
      • addAdditionalProperty

        protected void addAdditionalProperty​(java.lang.String name,
                                             java.lang.Object value)
      • addAdditionalInfoProperty

        protected void addAdditionalInfoProperty​(java.lang.String name,
                                                 java.lang.Object value)
      • getAdditionalInfoProperties

        protected java.util.Map getAdditionalInfoProperties()
      • readStringFromMetaData

        protected java.lang.String readStringFromMetaData​(java.util.Map meta_data,
                                                          java.lang.String name)
      • readStringFromMetaData

        protected java.lang.String readStringFromMetaData​(byte[] value)
      • writeStringToMetaData

        protected void writeStringToMetaData​(java.util.Map meta_data,
                                             java.lang.String name,
                                             java.lang.String value)
      • writeStringToMetaData

        protected byte[] writeStringToMetaData​(java.lang.String value)
      • anonymityTransform

        protected java.net.URL anonymityTransform​(java.net.URL url)
      • print

        public void print()
        Description copied from interface: TOTorrent
        A diagnostic method for dumping the tracker contents to "stdout"
        Specified by:
        print in interface TOTorrent
      • fireChanged

        protected void fireChanged​(int type)
      • getRelationText

        public java.lang.String getRelationText()
        Description copied from class: LogRelation
        A short description of what your class holds that can be printed by the logger
        Overrides:
        getRelationText in class LogRelation
        Returns:
      • getQueryableInterfaces

        public java.lang.Object[] getQueryableInterfaces()
        Description copied from class: LogRelation
        Query this class for a reference to another class that it may hold
        Overrides:
        getQueryableInterfaces in class LogRelation
        Returns:
        If found, the class desired. Otherwise, null.