org.eclipse.ecf.protocol.bittorrent
Class TorrentFactory

java.lang.Object
  extended by org.eclipse.ecf.protocol.bittorrent.TorrentFactory

public final class TorrentFactory
extends java.lang.Object

The TorrentFactory class allows for the creation of Torrents based on a TorrentFile with the createTorrent(TorrentFile) method.


Method Summary
static Torrent createTorrent(TorrentFile file)
          Creates a Torrent from the provided TorrentFile.
static Torrent[] getSavedTorrents()
          Gets all of the torrents that has been opened thus far based on where the state information has been saved as set by TorrentConfiguration.setConfigurationPath(File).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createTorrent

public static Torrent createTorrent(TorrentFile file)
                             throws java.lang.IllegalArgumentException,
                                    java.lang.IllegalStateException,
                                    java.io.IOException
Creates a Torrent from the provided TorrentFile.

Parameters:
file - the TorrentFile to use for instantiation
Returns:
a Torrent that wraps around the provided file to allow for exchanging of pieces with peers
Throws:
java.lang.IllegalArgumentException - If file is null
java.lang.IllegalStateException - If a configuration path has not yet been set via the TorrentConfiguration.setConfigurationPath(File) method
java.io.IOException - If an I/O error error occurs while creating or hooking onto the files specified by the file

getSavedTorrents

public static Torrent[] getSavedTorrents()
                                  throws java.lang.IllegalStateException,
                                         java.io.IOException
Gets all of the torrents that has been opened thus far based on where the state information has been saved as set by TorrentConfiguration.setConfigurationPath(File). Torrents can have its state information removed via the Torrent.remove() method, this will prevent it from being returned within this array.

Returns:
an array of previously opened Torrents
Throws:
java.lang.IllegalStateException - If the configuration path to search for torrents in has not yet been set
java.io.IOException - If an I/O error occurs while reading the configuration information or loading the torrent files