org.gudy.azureus2.pluginsimpl.local.torrent
Class TorrentManagerImpl

java.lang.Object
  extended by org.gudy.azureus2.pluginsimpl.local.torrent.TorrentManagerImpl
All Implemented Interfaces:
TOTorrentProgressListener, TorrentManager

public class TorrentManagerImpl
extends Object
implements TorrentManager, TOTorrentProgressListener


Field Summary
protected static CopyOnWriteList<TorrentManagerListener> listeners
           
protected  PluginInterface plugin_interface
           
 
Fields inherited from interface org.gudy.azureus2.plugins.torrent.TorrentManager
PRESERVE_ALL, PRESERVE_ENCODING, PRESERVE_NONE
 
Constructor Summary
protected TorrentManagerImpl(PluginInterface _pi)
           
 
Method Summary
 void addListener(TorrentManagerListener l)
           
 Torrent createFromBEncodedData(byte[] data)
          decodes a torrent encoded using the normal "bencoding" rules from a byte array
 Torrent createFromBEncodedData(byte[] data, int preserve)
          decodes a torrent encoded using the normal "bencoding" rules from a byte array
 Torrent createFromBEncodedFile(File file)
          decodes a torrent encoded using the normal "bencoding" rules from a file
 Torrent createFromBEncodedFile(File file, boolean for_seeding)
          decodes a torrent encoded using the normal "bencoding" rules from a file but discards the piece hashes to save memory.
 Torrent createFromBEncodedFile(File file, int preserve)
          decodes a torrent encoded using the normal "bencoding" rules from a file
 Torrent createFromBEncodedInputStream(InputStream data)
          decodes a torrent encoded using the normal "bencoding" rules from an InputStream
 Torrent createFromBEncodedInputStream(InputStream data, int preserve)
          decodes a torrent encoded using the normal "bencoding" rules from an InputStream
 Torrent createFromDataFile(File data, URL announce_url)
          creates a new torrent from an input file
 Torrent createFromDataFile(File data, URL announce_url, boolean include_other_hashes)
           
 TorrentCreator createFromDataFileEx(File data, URL announce_url, boolean include_other_hashes)
           
 TorrentAttribute getAttribute(String name)
          Gives access to the standard built-in attributes
 TorrentAttribute[] getDefinedAttributes()
          Gives access to the currently defined torrent attributes.
 TorrentAttribute getPluginAttribute(String name)
          Gives access to/creates arbitrary String attributes for plugins to use.
static TorrentManagerImpl getSingleton()
           
 TorrentDownloader getURLDownloader(URL url)
           
 TorrentDownloader getURLDownloader(URL url, String user_name, String password)
           
 void optionsAccepted(TorrentOpenOptions options)
           
 void optionsAdded(TorrentOpenOptions options)
           
 void optionsRemoved(TorrentOpenOptions options)
           
 void removeListener(TorrentManagerListener l)
           
 void reportCurrentTask(String task_description)
           
 void reportProgress(int percent_complete)
           
 TorrentManager specialise(PluginInterface _pi)
           
protected  void tryToSetDefaultTorrentEncoding(TOTorrent torrent)
           
protected  void tryToSetTorrentEncoding(TOTorrent torrent, String encoding)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

listeners

protected static CopyOnWriteList<TorrentManagerListener> listeners

plugin_interface

protected PluginInterface plugin_interface
Constructor Detail

TorrentManagerImpl

protected TorrentManagerImpl(PluginInterface _pi)
Method Detail

getSingleton

public static TorrentManagerImpl getSingleton()

specialise

public TorrentManager specialise(PluginInterface _pi)

getURLDownloader

public TorrentDownloader getURLDownloader(URL url)
                                   throws TorrentException
Specified by:
getURLDownloader in interface TorrentManager
Throws:
TorrentException

getURLDownloader

public TorrentDownloader getURLDownloader(URL url,
                                          String user_name,
                                          String password)
                                   throws TorrentException
Specified by:
getURLDownloader in interface TorrentManager
Throws:
TorrentException

createFromBEncodedFile

public Torrent createFromBEncodedFile(File file)
                               throws TorrentException
Description copied from interface: TorrentManager
decodes a torrent encoded using the normal "bencoding" rules from a file

Specified by:
createFromBEncodedFile in interface TorrentManager
Returns:
Throws:
TorrentException

createFromBEncodedFile

public Torrent createFromBEncodedFile(File file,
                                      boolean for_seeding)
                               throws TorrentException
Description copied from interface: TorrentManager
decodes a torrent encoded using the normal "bencoding" rules from a file but discards the piece hashes to save memory. note that this means that if something reads the hashes they will be re-read from the torrent file and if the file has since been deleted things go smelly

Specified by:
createFromBEncodedFile in interface TorrentManager
for_seeding - reduces memory usage by discarding piece hashes
Returns:
Throws:
TorrentException

createFromBEncodedInputStream

public Torrent createFromBEncodedInputStream(InputStream data)
                                      throws TorrentException
Description copied from interface: TorrentManager
decodes a torrent encoded using the normal "bencoding" rules from an InputStream

Specified by:
createFromBEncodedInputStream in interface TorrentManager
Returns:
Throws:
TorrentException

createFromBEncodedData

public Torrent createFromBEncodedData(byte[] data)
                               throws TorrentException
Description copied from interface: TorrentManager
decodes a torrent encoded using the normal "bencoding" rules from a byte array

Specified by:
createFromBEncodedData in interface TorrentManager
Returns:
Throws:
TorrentException

createFromDataFile

public Torrent createFromDataFile(File data,
                                  URL announce_url)
                           throws TorrentException
Description copied from interface: TorrentManager
creates a new torrent from an input file

Specified by:
createFromDataFile in interface TorrentManager
Returns:
Throws:
TorrentException

createFromDataFile

public Torrent createFromDataFile(File data,
                                  URL announce_url,
                                  boolean include_other_hashes)
                           throws TorrentException
Specified by:
createFromDataFile in interface TorrentManager
Throws:
TorrentException

createFromDataFileEx

public TorrentCreator createFromDataFileEx(File data,
                                           URL announce_url,
                                           boolean include_other_hashes)
                                    throws TorrentException
Specified by:
createFromDataFileEx in interface TorrentManager
Throws:
TorrentException

getDefinedAttributes

public TorrentAttribute[] getDefinedAttributes()
Description copied from interface: TorrentManager
Gives access to the currently defined torrent attributes. As of 2.1.0.2 only "category" is defined, however in the future more could be added such as "quality", "bit rate" etc.

Specified by:
getDefinedAttributes in interface TorrentManager
Returns:

getAttribute

public TorrentAttribute getAttribute(String name)
Description copied from interface: TorrentManager
Gives access to the standard built-in attributes

Specified by:
getAttribute in interface TorrentManager
Returns:

getPluginAttribute

public TorrentAttribute getPluginAttribute(String name)
Description copied from interface: TorrentManager
Gives access to/creates arbitrary String attributes for plugins to use. The attribute will be specific to the plugin, so you can use short torrent names like "name", you won't need to add the plugin ID or any other sort of unique identifier to the attribute name.

Specified by:
getPluginAttribute in interface TorrentManager
Returns:

createFromBEncodedData

public Torrent createFromBEncodedData(byte[] data,
                                      int preserve)
                               throws TorrentException
Description copied from interface: TorrentManager
decodes a torrent encoded using the normal "bencoding" rules from a byte array

Specified by:
createFromBEncodedData in interface TorrentManager
preserve - PRESERVE_* flags
Returns:
Throws:
TorrentException

createFromBEncodedFile

public Torrent createFromBEncodedFile(File file,
                                      int preserve)
                               throws TorrentException
Description copied from interface: TorrentManager
decodes a torrent encoded using the normal "bencoding" rules from a file

Specified by:
createFromBEncodedFile in interface TorrentManager
preserve - PRESERVE_* flags
Returns:
Throws:
TorrentException

createFromBEncodedInputStream

public Torrent createFromBEncodedInputStream(InputStream data,
                                             int preserve)
                                      throws TorrentException
Description copied from interface: TorrentManager
decodes a torrent encoded using the normal "bencoding" rules from an InputStream

Specified by:
createFromBEncodedInputStream in interface TorrentManager
preserve - PRESERVE_* flags
Returns:
Throws:
TorrentException

reportProgress

public void reportProgress(int percent_complete)
Specified by:
reportProgress in interface TOTorrentProgressListener

reportCurrentTask

public void reportCurrentTask(String task_description)
Specified by:
reportCurrentTask in interface TOTorrentProgressListener

tryToSetTorrentEncoding

protected void tryToSetTorrentEncoding(TOTorrent torrent,
                                       String encoding)
                                throws TorrentEncodingException
Throws:
TorrentEncodingException

tryToSetDefaultTorrentEncoding

protected void tryToSetDefaultTorrentEncoding(TOTorrent torrent)
                                       throws TorrentException
Throws:
TorrentException

optionsAdded

public void optionsAdded(TorrentOpenOptions options)

optionsAccepted

public void optionsAccepted(TorrentOpenOptions options)

optionsRemoved

public void optionsRemoved(TorrentOpenOptions options)

addListener

public void addListener(TorrentManagerListener l)
Specified by:
addListener in interface TorrentManager

removeListener

public void removeListener(TorrentManagerListener l)
Specified by:
removeListener in interface TorrentManager