Methods Summary |
---|
public void | asyncDownload()
try{
this_mon.enter();
if ( !cancelled ){
current_downloader = delegate.getClone( this );
informActivity( getLogIndent() + "Downloading: " + getName());
current_downloader.addListener( this );
current_downloader.asyncDownload();
Thread t = new AEThread( "ResourceDownloaderTimeout")
{
public void
runSupport()
{
try{
Thread.sleep( timeout_millis );
cancel(new ResourceDownloaderException( "Download timeout"));
}catch( Throwable e ){
Debug.printStackTrace( e );
}
}
};
t.setDaemon(true);
t.start();
}
}finally{
this_mon.exit();
}
|
public void | asyncGetSize()
try{
this_mon.enter();
if ( !cancelled ){
current_downloader = delegate.getClone( this );
Thread size_thread = new AEThread( "ResourceDownloader:size getter" )
{
public void
runSupport()
{
try{
long res = current_downloader.getSize();
result = new Long(res);
setProperties( current_downloader );
done_sem.release();
}catch( ResourceDownloaderException e ){
failed( current_downloader, e );
}
}
};
size_thread.setDaemon( true );
size_thread.start();
Thread t = new AEThread( "ResourceDownloaderTimeout")
{
public void
runSupport()
{
try{
Thread.sleep( timeout_millis );
cancel(new ResourceDownloaderException( "getSize timeout"));
}catch( Throwable e ){
Debug.printStackTrace( e );
}
}
};
t.setDaemon(true);
t.start();
}
}finally{
this_mon.exit();
}
|
public void | cancel()
cancel( new ResourceDownloaderException( "Download cancelled"));
|
protected void | cancel(ResourceDownloaderException reason)
setCancelled();
try{
this_mon.enter();
result = reason;
cancelled = true;
informFailed((ResourceDownloaderException)result );
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()
asyncDownload();
done_sem.reserve();
if ( result instanceof InputStream ){
return((InputStream)result);
}
throw((ResourceDownloaderException)result);
|
public void | failed(ResourceDownloader downloader, ResourceDownloaderException e)
result = e;
done_sem.release();
informFailed( e );
|
public ResourceDownloaderBaseImpl | getClone(ResourceDownloaderBaseImpl parent)
ResourceDownloaderTimeoutImpl c = new ResourceDownloaderTimeoutImpl( getParent(), delegate.getClone( parent ), timeout_millis );
c.setSize( size );
c.setProperties( this );
return( c );
|
public java.lang.String | getName()
return( delegate.getName() + ": timeout=" + timeout_millis );
|
public long | getSize()
if ( size != -2 ){
return( size );
}
try{
ResourceDownloaderTimeoutImpl x = new ResourceDownloaderTimeoutImpl( getParent(), delegate.getClone( this ), timeout_millis );
addReportListener( x );
size = x.getSizeSupport();
setProperties( x );
}finally{
if ( size == -2 ){
size = -1;
}
setSize( size );
}
return( size );
|
protected long | getSizeSupport()
asyncGetSize();
done_sem.reserve();
if ( result instanceof Long ){
return(((Long)result).longValue());
}
throw((ResourceDownloaderException)result);
|
protected void | setProperty(java.lang.String name, java.lang.Object value)
setPropertySupport( name, value );
delegate.setProperty( name, value );
|
protected void | setSize(long l)
size = l;
if ( size >= 0 ){
delegate.setSize( size );
}
|