FileDocCategorySizeDatePackage
ResourceDownloaderFactoryImpl.javaAPI DocAzureus 3.0.3.45424Wed May 30 22:51:40 BST 2007org.gudy.azureus2.pluginsimpl.local.utils.resourcedownloader

ResourceDownloaderFactoryImpl

public class ResourceDownloaderFactoryImpl extends Object implements ResourceDownloaderFactory
author
parg

Fields Summary
private static final LogIDs
LOGID
protected static ResourceDownloaderFactoryImpl
singleton
Constructors Summary
Methods Summary
public ResourceDownloadercreate(java.io.File file)

		return( new ResourceDownloaderFileImpl( null, file ));
	
public ResourceDownloadercreate(java.net.URL url)

		if ( url.getProtocol().equalsIgnoreCase("file")){
			
			try{
				return( new ResourceDownloaderFileImpl( null, new File( new URI( url.toString()))));
			
			}catch( Throwable e ){
				
				return( new ResourceDownloaderURLImpl( null, url ));
			}
		}else{
			
			return( new ResourceDownloaderURLImpl( null, url ));
		}
	
public ResourceDownloadercreate(java.net.URL url, java.lang.String postData)

		return new ResourceDownloaderURLImpl(null, url, postData, false, null, null);
	
public ResourceDownloadercreate(java.net.URL url, java.lang.String user_name, java.lang.String password)

		return( new ResourceDownloaderURLImpl( null, url, user_name, password ));
	
public ResourceDownloadercreate(ResourceDownloaderDelayedFactory factory)

		return( new ResourceDownloaderDelayedImpl( null, factory ));
	
public ResourceDownloadergetAlternateDownloader(ResourceDownloader[] downloaders, int max_to_try)

		return( getAlternateDownloader( downloaders, max_to_try, false ));
	
protected ResourceDownloadergetAlternateDownloader(ResourceDownloader[] downloaders, int max_to_try, boolean random)

		ResourceDownloader res = new ResourceDownloaderAlternateImpl( null, downloaders, max_to_try, random );
				
		return( res );
	
public ResourceDownloadergetAlternateDownloader(ResourceDownloader[] downloaders)

		return( getAlternateDownloader( downloaders, -1, false ));
	
public ResourceDownloadergetMetaRefreshDownloader(ResourceDownloader downloader)

		ResourceDownloader res = new ResourceDownloaderMetaRefreshImpl( null, downloader );
				
		return( res );
	
public ResourceDownloadergetRandomDownloader(ResourceDownloader[] downloaders)

		return( getAlternateDownloader( downloaders, -1, true ));
	
public ResourceDownloadergetRandomDownloader(ResourceDownloader[] downloaders, int max_to_try)

		return( getAlternateDownloader( downloaders, max_to_try, true ));
	
public ResourceDownloadergetRetryDownloader(ResourceDownloader downloader, int retry_count)

		ResourceDownloader res = new ResourceDownloaderRetryImpl( null, downloader, retry_count );

		return( res );
	
public static ResourceDownloaderFactorygetSingleton()

	
	  
	
	
		return( singleton );
	
public ResourceDownloadergetSuffixBasedDownloader(ResourceDownloader _downloader)

		ResourceDownloaderBaseImpl	dl = (ResourceDownloaderBaseImpl)_downloader;
		
		URL	target = null;
		
		while( true ){
			
			List	kids = dl.getChildren();
			
			if ( kids.size() == 0 ){
				
				target = ((ResourceDownloaderURLImpl)dl).getURL();
				
				break;
			}
			
			dl = (ResourceDownloaderBaseImpl)kids.get(0);
		}
		
		if ( target == null ){
			
			if (Logger.isEnabled())
				Logger.log(new LogEvent(LOGID, "ResourceDownloader: suffix "
						+ "based downloader failed to find leaf"));
			
			return( _downloader );
		}
		
		if ( target.getPath().toLowerCase().endsWith(".torrent")){
			
			return( getTorrentDownloader( _downloader, true ));
			
		}else{
			
			return( _downloader );
		}
	
public ResourceDownloadergetTimeoutDownloader(ResourceDownloader downloader, int timeout_millis)

		ResourceDownloader res = new ResourceDownloaderTimeoutImpl( null, downloader, timeout_millis );
		
		return( res );
	
public ResourceDownloadergetTorrentDownloader(ResourceDownloader downloader, boolean persistent)

		return( getTorrentDownloader( downloader, persistent, null ));
	
public ResourceDownloadergetTorrentDownloader(ResourceDownloader downloader, boolean persistent, java.io.File download_directory)

		return( new ResourceDownloaderTorrentImpl( null, downloader, persistent, download_directory ));