Class ResourceDownloaderTorrentImpl
- java.lang.Object
-
- com.biglybt.pifimpl.local.utils.resourcedownloader.ResourceDownloaderBaseImpl
-
- com.biglybt.pifimpl.local.utils.resourcedownloader.ResourceDownloaderTorrentImpl
-
- All Implemented Interfaces:
ResourceDownloader
,ResourceDownloaderListener
public class ResourceDownloaderTorrentImpl extends ResourceDownloaderBaseImpl implements ResourceDownloaderListener
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
cancelled
protected boolean
completed
protected ResourceDownloader
current_downloader
protected ResourceDownloaderBaseImpl
delegate
protected AESemaphore
done_sem
protected Download
download
protected java.io.File
download_dir
protected DownloadManager
download_manager
static int
MAX_FOLLOWS
protected boolean
persistent
protected java.lang.Object
result
protected long
size
protected TOTorrent[]
torrent_holder
-
Fields inherited from class com.biglybt.pifimpl.local.utils.resourcedownloader.ResourceDownloaderBaseImpl
this_mon
-
Fields inherited from interface com.biglybt.pif.utils.resourcedownloader.ResourceDownloader
PR_BOOLEAN_ANONYMOUS, PR_STRING_CONTENT_TYPE
-
-
Constructor Summary
Constructors Constructor Description ResourceDownloaderTorrentImpl(ResourceDownloaderBaseImpl _parent, ResourceDownloader _delegate, boolean _persistent, java.io.File _download_dir)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
asyncDownload()
Asynchronously download.void
cancel()
Cancel the download.boolean
completed(ResourceDownloader downloader, java.io.InputStream data)
java.io.InputStream
download()
Synchronously download.protected void
downloadRemoved(java.io.File torrent_file, java.io.File data_dir)
protected void
downloadSucceeded(Download download, java.io.File torrent_file, java.io.File data_dir)
protected void
downloadTorrent()
void
failed(ResourceDownloader downloader, ResourceDownloaderException e)
ResourceDownloaderBaseImpl
getClone(ResourceDownloaderBaseImpl parent)
java.lang.String
getName()
Get a sensible name for the download based on its details (e.g.long
getSize()
Attempts to get the size of the download.protected long
getSizeSupport()
void
reportPercentComplete(ResourceDownloader downloader, int percentage)
void
setProperty(java.lang.String name, java.lang.Object value)
protected void
setSize(long l)
protected void
setSizeAndTorrent(long _size, TOTorrent[] _torrent_holder)
-
Methods inherited from class com.biglybt.pifimpl.local.utils.resourcedownloader.ResourceDownloaderBaseImpl
addChild, addListener, addReportListener, getBooleanProperty, getBooleanProperty, getChildren, getClone, getLCKeyProperties, getLogIndent, getLongProperty, getParent, getProperty, getProperty, getPropertySupport, getStringProperty, getStringPropertySupport, informActivity, informAmountComplete, informComplete, informFailed, informPercentDone, isAnonymous, isCancelled, removeChild, removeListener, reportActivity, reportActivity, reportAmountComplete, setCancelled, setParent, setProperties, setPropertiesSet, setPropertyRecursive, setPropertySupport
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.biglybt.pif.utils.resourcedownloader.ResourceDownloaderListener
reportActivity, reportAmountComplete
-
-
-
-
Field Detail
-
MAX_FOLLOWS
public static final int MAX_FOLLOWS
- See Also:
- Constant Field Values
-
delegate
protected ResourceDownloaderBaseImpl delegate
-
persistent
protected boolean persistent
-
download_dir
protected java.io.File download_dir
-
size
protected long size
-
torrent_holder
protected TOTorrent[] torrent_holder
-
download_manager
protected DownloadManager download_manager
-
download
protected Download download
-
cancelled
protected boolean cancelled
-
completed
protected boolean completed
-
current_downloader
protected ResourceDownloader current_downloader
-
result
protected java.lang.Object result
-
done_sem
protected AESemaphore done_sem
-
-
Constructor Detail
-
ResourceDownloaderTorrentImpl
public ResourceDownloaderTorrentImpl(ResourceDownloaderBaseImpl _parent, ResourceDownloader _delegate, boolean _persistent, java.io.File _download_dir)
-
-
Method Detail
-
getName
public java.lang.String getName()
Description copied from interface:ResourceDownloader
Get a sensible name for the download based on its details (e.g. URL)- Specified by:
getName
in interfaceResourceDownloader
- Returns:
-
getSize
public long getSize() throws ResourceDownloaderException
Description copied from interface:ResourceDownloader
Attempts to get the size of the download. Returns -1 if the size can't be determined.Note: You must not call this method from the reportActivity callback method.
- Specified by:
getSize
in interfaceResourceDownloader
- Throws:
ResourceDownloaderException
-
setSize
protected void setSize(long l)
- Specified by:
setSize
in classResourceDownloaderBaseImpl
-
setProperty
public void setProperty(java.lang.String name, java.lang.Object value) throws ResourceDownloaderException
- Specified by:
setProperty
in interfaceResourceDownloader
- Throws:
ResourceDownloaderException
-
getSizeSupport
protected long getSizeSupport() throws ResourceDownloaderException
- Throws:
ResourceDownloaderException
-
setSizeAndTorrent
protected void setSizeAndTorrent(long _size, TOTorrent[] _torrent_holder)
-
getClone
public ResourceDownloaderBaseImpl getClone(ResourceDownloaderBaseImpl parent)
- Specified by:
getClone
in classResourceDownloaderBaseImpl
-
download
public java.io.InputStream download() throws ResourceDownloaderException
Description copied from interface:ResourceDownloader
Synchronously download. Events are still reported to listeners- Specified by:
download
in interfaceResourceDownloader
- Returns:
- Throws:
ResourceDownloaderException
-
asyncDownload
public void asyncDownload()
Description copied from interface:ResourceDownloader
Asynchronously download.- Specified by:
asyncDownload
in interfaceResourceDownloader
-
downloadTorrent
protected void downloadTorrent()
-
downloadSucceeded
protected void downloadSucceeded(Download download, java.io.File torrent_file, java.io.File data_dir)
-
downloadRemoved
protected void downloadRemoved(java.io.File torrent_file, java.io.File data_dir)
-
cancel
public void cancel()
Description copied from interface:ResourceDownloader
Cancel the download.- Specified by:
cancel
in interfaceResourceDownloader
-
completed
public boolean completed(ResourceDownloader downloader, java.io.InputStream data)
- Specified by:
completed
in interfaceResourceDownloaderListener
- Returns:
- return true if the completed download is OK. If false is returned then if there are alternative download sources they will be tried. If there are no other sources then the download will be "failed"
-
failed
public void failed(ResourceDownloader downloader, ResourceDownloaderException e)
- Specified by:
failed
in interfaceResourceDownloaderListener
-
reportPercentComplete
public void reportPercentComplete(ResourceDownloader downloader, int percentage)
- Specified by:
reportPercentComplete
in interfaceResourceDownloaderListener
- Overrides:
reportPercentComplete
in classResourceDownloaderBaseImpl
-
-