Interface TOTorrent

    • Field Detail

      • DEFAULT_IGNORE_FILES

        static final java.lang.String DEFAULT_IGNORE_FILES
        See Also:
        Constant Field Values
      • AZUREUS_PROPERTIES

        static final java.lang.String AZUREUS_PROPERTIES
        A Map additional property defined for holding AZ specific properties that are deemed to be exportable to the world
        See Also:
        Constant Field Values
      • AZUREUS_PRIVATE_PROPERTIES

        static final java.lang.String AZUREUS_PRIVATE_PROPERTIES
        These ones are *not* exportable to the world
        See Also:
        Constant Field Values
      • ENCODING_ACTUALLY_UTF8_KEYS

        static final java.lang.String ENCODING_ACTUALLY_UTF8_KEYS
        See Also:
        Constant Field Values
    • Method Detail

      • getTorrentType

        int getTorrentType()
        Returns:
        One of the TT_ constants
      • getEffectiveTorrentType

        default int getEffectiveTorrentType()
        For hybrid torrents this indicates whether it is acting as a v1 or v2 swarm
        Returns:
      • isExportable

        boolean isExportable()
        Is the torrent in a fit state to export and share?
        Returns:
      • updateExportability

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

        byte[] getName()
        Get the name of the torrent
        Returns:
      • isSimpleTorrent

        boolean isSimpleTorrent()
        A "simple torrent" is one that consists of a single file on its own (i.e. not in a nested directory).
        Returns:
      • getComment

        byte[] getComment()
        Comment is an optional torrent property
        Returns:
      • setComment

        void setComment​(java.lang.String comment)
      • getCreationDate

        long getCreationDate()
        Gets the creation date of the torrent. Optional property, 0 returned if not set
        Returns:
      • setCreationDate

        void setCreationDate​(long date)
      • getCreatedBy

        byte[] getCreatedBy()
      • setCreatedBy

        void setCreatedBy​(byte[] cb)
      • isCreated

        boolean isCreated()
      • getAnnounceURL

        java.net.URL getAnnounceURL()
        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
        Returns:
      • setAnnounceURL

        boolean setAnnounceURL​(java.net.URL url)
        Parameters:
        url -
        Returns:
        true-changed; false-not changed
      • getAnnounceURLGroup

        TOTorrentAnnounceURLGroup getAnnounceURLGroup()
        When a group of sets of trackers is defined their URLs are accessed via this method
        Returns:
        the group, always present, which may have 0 members
      • isDecentralised

        boolean isDecentralised()
      • getPieces

        byte[][] getPieces()
                    throws TOTorrentException
        This method provides access to the SHA1/SHA256 hash values (20/32 bytes each) that correspond to the pieces of the torrent.
        Returns:
        Throws:
        can - fail if re-reading of piece hashes for space spacing fails
        TOTorrentException
      • setPieces

        void setPieces​(byte[][] pieces)
                throws TOTorrentException
        This method exists to support the temporary discarding of piece hashes to conserver memory. It should only be used with care!
        Parameters:
        pieces -
        Throws:
        TOTorrentException
      • getPieceLength

        long getPieceLength()
        Returns the piece length used for the torrent
        Returns:
      • getNumberOfPieces

        int getNumberOfPieces()
      • getSize

        long getSize()
      • getFileCount

        int getFileCount()
      • getFiles

        TOTorrentFile[] getFiles()
        A torrent consists of one or more files. These are accessed via this method.
        Returns:
      • getHash

        byte[] getHash()
                throws TOTorrentException
        For a V1 or hybrid torrent this returns the SHA1 hash For a V2 only torrent it returns the truncated SHA256 hash
        Returns:
        Throws:
        TOTorrentException
      • hasSameHashAs

        boolean hasSameHashAs​(TOTorrent other)
        compares two torrents by hash
        Parameters:
        other -
        Returns:
      • getPrivate

        boolean getPrivate()
      • setPrivate

        void setPrivate​(boolean _private)
                 throws TOTorrentException
        Note - changing the private attribute CHANGES THE TORRENT HASH
        Parameters:
        _private -
        Throws:
        TOTorrentException
      • setSource

        void setSource​(java.lang.String source)
                throws TOTorrentException
        Note - changing the source CHANGES THE TORRENT HASH
        Parameters:
        source -
        Throws:
        TOTorrentException
      • getSource

        java.lang.String getSource()
      • setAdditionalStringProperty

        void setAdditionalStringProperty​(java.lang.String name,
                                         java.lang.String value)
        The additional properties are used for holding non-core data for Azureus' own user
        Parameters:
        name - name of the property (e.g. "encoding")
        value - value. This will be encoded with default encoding
      • getAdditionalStringProperty

        java.lang.String getAdditionalStringProperty​(java.lang.String name)
      • setAdditionalByteArrayProperty

        void setAdditionalByteArrayProperty​(java.lang.String name,
                                            byte[] value)
      • getAdditionalByteArrayProperty

        byte[] getAdditionalByteArrayProperty​(java.lang.String name)
      • setAdditionalLongProperty

        void setAdditionalLongProperty​(java.lang.String name,
                                       java.lang.Long value)
      • getAdditionalLongProperty

        java.lang.Long getAdditionalLongProperty​(java.lang.String name)
      • setAdditionalListProperty

        void setAdditionalListProperty​(java.lang.String name,
                                       java.util.List value)
      • getAdditionalListProperty

        java.util.List getAdditionalListProperty​(java.lang.String name)
      • setAdditionalMapProperty

        void setAdditionalMapProperty​(java.lang.String name,
                                      java.util.Map value)
      • getAdditionalMapProperty

        java.util.Map getAdditionalMapProperty​(java.lang.String name)
      • getAdditionalProperty

        java.lang.Object getAdditionalProperty​(java.lang.String name)
      • setAdditionalProperty

        void setAdditionalProperty​(java.lang.String name,
                                   java.lang.Object value)
        set an arbitrary property. Make sure its compatible with bencoding!
      • removeAdditionalProperty

        void removeAdditionalProperty​(java.lang.String name)
      • removeAdditionalProperties

        void removeAdditionalProperties()
        remove all additional properties to clear out the torrent
      • serialiseToBEncodedFile

        void serialiseToBEncodedFile​(java.io.File file)
                              throws TOTorrentException
        This method will serialise a torrent using the standard "b-encoding" mechanism into a file
        Parameters:
        file -
        Throws:
        TOTorrentException
      • serialiseToMap

        java.util.Map serialiseToMap()
                              throws TOTorrentException
        This method will serialise a torrent into a Map consistent with that used by the "b-encoding" routines defined elsewhere
        Returns:
        Throws:
        TOTorrentException
      • serialiseToXMLFile

        void serialiseToXMLFile​(java.io.File file)
                         throws TOTorrentException
        This method will serialise a torrent using an XML encoding to a file
        Parameters:
        file -
        Throws:
        TOTorrentException
      • print

        void print()
        A diagnostic method for dumping the tracker contents to "stdout"
      • getUTF8Name

        java.lang.String getUTF8Name()
        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)