Methods Summary |
---|
public void | asyncDownload()
try{
this_mon.enter();
if ( !cancelled ){
informActivity( getLogIndent() + ( file.isDirectory()?"Processing: ":"Downloading: " ) + getName());
Thread t = new AEThread( "ResourceDownloaderTimeout")
{
public void
runSupport()
{
try{
// download of a local dir -> null inputstream
if ( file.isDirectory()){
completed( ResourceDownloaderFileImpl.this, null );
}else{
completed( ResourceDownloaderFileImpl.this, new FileInputStream( file ));
}
}catch( Throwable e ){
failed( ResourceDownloaderFileImpl.this, new ResourceDownloaderException( "Failed to read file", e ));
Debug.printStackTrace( e );
}
}
};
t.setDaemon(true);
t.start();
}
}finally{
this_mon.exit();
}
|
protected void | cancel(org.gudy.azureus2.plugins.utils.resourcedownloader.ResourceDownloaderException reason)
setCancelled();
try{
this_mon.enter();
result = reason;
cancelled = true;
informFailed((ResourceDownloaderException)result );
}finally{
this_mon.exit();
}
|
public void | cancel()
cancel( new ResourceDownloaderException( "Download cancelled"));
|
public boolean | completed(org.gudy.azureus2.plugins.utils.resourcedownloader.ResourceDownloader downloader, java.io.InputStream data)
if (informComplete( data )){
result = data;
done_sem.release();
return( true );
}
return( false );
|
public java.io.InputStream | download()
asyncDownload();
done_sem.reserve();
if ( result instanceof ResourceDownloaderException ){
throw((ResourceDownloaderException)result);
}
return((InputStream)result);
|
public void | failed(org.gudy.azureus2.plugins.utils.resourcedownloader.ResourceDownloader downloader, org.gudy.azureus2.plugins.utils.resourcedownloader.ResourceDownloaderException e)
result = e;
done_sem.release();
informFailed( e );
|
public ResourceDownloaderBaseImpl | getClone(ResourceDownloaderBaseImpl parent)
ResourceDownloaderFileImpl c = new ResourceDownloaderFileImpl( getParent(), file );
return( c );
|
public java.lang.String | getName()
return( file.toString());
|
public long | getSize()
String file_str = file.toString();
int pos = file_str.lastIndexOf( "." );
String file_type;
if ( pos != -1 ){
file_type = file_str.substring(pos+1);
}else{
file_type = null;
}
setProperty( ResourceDownloader.PR_STRING_CONTENT_TYPE,
HTTPUtils.guessContentTypeFromFileType( file_type ));
return( FileUtil.getFileOrDirectorySize( file ));
|
protected void | setProperty(java.lang.String name, java.lang.Object value)
setPropertySupport( name, value );
|
protected void | setSize(long size)
|