org.gudy.azureus2.pluginsimpl.local.utils.resourcedownloader
Class ResourceDownloaderTimeoutImpl

java.lang.Object
  extended by org.gudy.azureus2.pluginsimpl.local.utils.resourcedownloader.ResourceDownloaderBaseImpl
      extended by org.gudy.azureus2.pluginsimpl.local.utils.resourcedownloader.ResourceDownloaderTimeoutImpl
All Implemented Interfaces:
ResourceDownloader, ResourceDownloaderListener

public class ResourceDownloaderTimeoutImpl
extends ResourceDownloaderBaseImpl
implements ResourceDownloaderListener


Field Summary
protected  boolean cancelled
           
protected  ResourceDownloaderBaseImpl current_downloader
           
protected  ResourceDownloaderBaseImpl delegate
           
protected  AESemaphore done_sem
           
protected  Object result
           
protected  long size
           
protected  int timeout_millis
           
 
Fields inherited from class org.gudy.azureus2.pluginsimpl.local.utils.resourcedownloader.ResourceDownloaderBaseImpl
this_mon
 
Fields inherited from interface org.gudy.azureus2.plugins.utils.resourcedownloader.ResourceDownloader
PR_STRING_CONTENT_TYPE
 
Constructor Summary
ResourceDownloaderTimeoutImpl(ResourceDownloaderBaseImpl _parent, ResourceDownloader _delegate, int _timeout_millis)
           
 
Method Summary
 void asyncDownload()
          Asynchronously download.
 void asyncGetSize()
           
 void cancel()
          Cancel the download.
protected  void cancel(ResourceDownloaderException reason)
           
 boolean completed(ResourceDownloader downloader, InputStream data)
           
 InputStream download()
          Synchronously download.
 void failed(ResourceDownloader downloader, ResourceDownloaderException e)
           
 ResourceDownloaderBaseImpl getClone(ResourceDownloaderBaseImpl parent)
           
 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 setProperty(String name, Object value)
           
protected  void setSize(long l)
           
 
Methods inherited from class org.gudy.azureus2.pluginsimpl.local.utils.resourcedownloader.ResourceDownloaderBaseImpl
addChild, addListener, addReportListener, getBooleanProperty, getChildren, getClone, getLCKeyProperties, getLogIndent, getLongProperty, getParent, getProperty, getPropertySupport, getStringProperty, getStringPropertySupport, informActivity, informAmountComplete, informComplete, informFailed, informPercentDone, isCancelled, removeChild, removeListener, reportActivity, reportActivity, reportAmountComplete, reportPercentComplete, setCancelled, setParent, setProperties, setPropertiesSet, setPropertySupport
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.gudy.azureus2.plugins.utils.resourcedownloader.ResourceDownloaderListener
reportActivity, reportAmountComplete, reportPercentComplete
 

Field Detail

delegate

protected ResourceDownloaderBaseImpl delegate

timeout_millis

protected int timeout_millis

cancelled

protected boolean cancelled

current_downloader

protected ResourceDownloaderBaseImpl current_downloader

result

protected Object result

done_sem

protected AESemaphore done_sem

size

protected long size
Constructor Detail

ResourceDownloaderTimeoutImpl

public ResourceDownloaderTimeoutImpl(ResourceDownloaderBaseImpl _parent,
                                     ResourceDownloader _delegate,
                                     int _timeout_millis)
Method Detail

getName

public 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 interface ResourceDownloader
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 interface ResourceDownloader
Throws:
ResourceDownloaderException

setSize

protected void setSize(long l)
Specified by:
setSize in class ResourceDownloaderBaseImpl

setProperty

public void setProperty(String name,
                        Object value)
                 throws ResourceDownloaderException
Specified by:
setProperty in interface ResourceDownloader
Throws:
ResourceDownloaderException

getClone

public ResourceDownloaderBaseImpl getClone(ResourceDownloaderBaseImpl parent)
Specified by:
getClone in class ResourceDownloaderBaseImpl

download

public InputStream download()
                     throws ResourceDownloaderException
Description copied from interface: ResourceDownloader
Synchronously download. Events are still reported to listeners

Specified by:
download in interface ResourceDownloader
Returns:
Throws:
ResourceDownloaderException

asyncDownload

public void asyncDownload()
Description copied from interface: ResourceDownloader
Asynchronously download.

Specified by:
asyncDownload in interface ResourceDownloader

getSizeSupport

protected long getSizeSupport()
                       throws ResourceDownloaderException
Throws:
ResourceDownloaderException

asyncGetSize

public void asyncGetSize()

cancel

public void cancel()
Description copied from interface: ResourceDownloader
Cancel the download.

Specified by:
cancel in interface ResourceDownloader

cancel

protected void cancel(ResourceDownloaderException reason)

completed

public boolean completed(ResourceDownloader downloader,
                         InputStream data)
Specified by:
completed in interface ResourceDownloaderListener
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 interface ResourceDownloaderListener