Methods Summary |
---|
public void | asyncDownload()
try{
this_mon.enter();
if ( current_index == max_to_try || cancelled ){
done_sem.release();
informFailed((ResourceDownloaderException)result);
}else{
current_downloader = ((ResourceDownloaderBaseImpl)delegates[current_index]).getClone( this );
informActivity( getLogIndent() + "Downloading: " + getName());
current_index++;
current_downloader.addListener( this );
current_downloader.asyncDownload();
}
}finally{
this_mon.exit();
}
|
public void | cancel()
setCancelled();
try{
this_mon.enter();
result = new ResourceDownloaderException( "Download cancelled");
cancelled = true;
informFailed((ResourceDownloaderException)result );
done_sem.release();
if ( current_downloader != null ){
current_downloader.cancel();
}
}finally{
this_mon.exit();
}
|
public boolean | completed(ResourceDownloader downloader, java.io.InputStream data)
if ( informComplete( data )){
result = data;
done_sem.release();
return( true );
}
return( false );
|
public java.io.InputStream | download()
if( delegates.length == 0 ){
ResourceDownloaderException error = new ResourceDownloaderException( "Alternate download fails - 0 alteratives");
informFailed( error );
throw( error );
}
asyncDownload();
done_sem.reserve();
if ( result instanceof InputStream ){
return((InputStream)result);
}
throw((ResourceDownloaderException)result);
|
public void | failed(ResourceDownloader downloader, ResourceDownloaderException e)
result = e;
asyncDownload();
|
public ResourceDownloaderBaseImpl | getClone(ResourceDownloaderBaseImpl parent)
ResourceDownloader[] clones = new ResourceDownloader[delegates.length];
for (int i=0;i<delegates.length;i++){
clones[i] = ((ResourceDownloaderBaseImpl)delegates[i]).getClone( this );
}
ResourceDownloaderAlternateImpl c =
new ResourceDownloaderAlternateImpl( parent, clones, max_to_try, random );
c.setSize(size);
c.setProperties( this );
return( c );
|
public java.lang.String | getName()
String res = "[";
for (int i=0;i<delegates.length;i++){
res += (i==0?"":",") + delegates[i].getName();
}
return( res + "]");
|
public long | getSize()
if( delegates.length == 0 ){
ResourceDownloaderException error = new ResourceDownloaderException( "Alternate download fails - 0 alteratives");
informFailed( error );
throw( error );
}
if ( size != -2 ){
return( size );
}
try{
for (int i=0;i<max_to_try;i++){
try{
ResourceDownloaderBaseImpl c = ((ResourceDownloaderBaseImpl)delegates[i]).getClone( this );
addReportListener( c );
size = c.getSize();
setProperties( c );
break;
}catch( ResourceDownloaderException e ){
if ( i == delegates.length-1 ){
throw( e );
}
}
}
}finally{
if ( size == -2 ){
size = -1;
}
setSize( size );
}
return( size );
|
protected void | setProperty(java.lang.String name, java.lang.Object value)
setPropertySupport( name, value );
for (int i=0;i<delegates.length;i++){
((ResourceDownloaderBaseImpl)delegates[i]).setProperty( name, value );
}
|
protected void | setSize(long l)
size = l;
if ( size >= 0 ){
for (int i=0;i<delegates.length;i++){
((ResourceDownloaderBaseImpl)delegates[i]).setSize( size );
}
}
|