FileDocCategorySizeDatePackage
TRTrackerScraperImpl.javaAPI DocAzureus 3.0.3.45629Sun Jul 16 03:35:20 BST 2006org.gudy.azureus2.core3.tracker.client.impl

TRTrackerScraperImpl

public class TRTrackerScraperImpl extends Object implements TRTrackerScraper
author
parg

Fields Summary
private static TRTrackerScraperImpl
singleton
private static AEMonitor
class_mon
private org.gudy.azureus2.core3.tracker.client.impl.bt.TRTrackerBTScraperImpl
bt_scraper
private org.gudy.azureus2.core3.tracker.client.impl.dht.TRTrackerDHTScraperImpl
dht_scraper
private TRTrackerScraperClientResolver
client_resolver
private static final int
LDT_SCRAPE_RECEIVED
private ListenerManager
listeners
Constructors Summary
protected TRTrackerScraperImpl()

		bt_scraper 	= TRTrackerBTScraperImpl.create( this );
		
		dht_scraper	= TRTrackerDHTScraperImpl.create( this );
	
Methods Summary
public voidaddListener(TRTrackerScraperListener l)

		listeners.addListener(l);
	
public static org.gudy.azureus2.core3.tracker.client.impl.TRTrackerScraperImplcreate()

	
	
	  
	
	
		try{
			class_mon.enter();
		
			if ( singleton == null ){
			
				singleton =  new TRTrackerScraperImpl();
			}
			
			return( singleton );
		}finally{
			
			class_mon.exit();
		}
	
public java.lang.Object[]getExtensions(HashWrapper hash)

		if ( client_resolver == null ){
			
			return( null );
		}
		
		return( client_resolver.getExtensions( hash ));
	
public booleanisNetworkEnabled(HashWrapper hash, java.net.URL url)

		if ( client_resolver == null ){
			
			return( false );
		}
		
		return( client_resolver.isNetworkEnabled( hash, url ));
	
public booleanisTorrentDownloading(HashWrapper hash)

		if ( client_resolver == null ){
			
			return( false );
		}
		
		int	state = client_resolver.getStatus( hash );
		
		return( state == TRTrackerScraperClientResolver.ST_RUNNING );
	
public booleanisTorrentRunning(HashWrapper hash)

		if ( client_resolver == null ){
			
			return( false );
		}
		
		int	state = client_resolver.getStatus( hash );
		
		return( state == TRTrackerScraperClientResolver.ST_RUNNING || state == TRTrackerScraperClientResolver.ST_QUEUED );
	
public booleanredirectTrackerUrl(HashWrapper hash, java.net.URL old_url, java.net.URL new_url)

		return( client_resolver.redirectTrackerUrl( hash, old_url, new_url ));
	
public voidremove(TOTorrent torrent)

		if ( TorrentUtils.isDecentralised( torrent )){

			dht_scraper.remove( torrent );

		}else{
		
			bt_scraper.remove( torrent );
		}
	
public voidremoveListener(TRTrackerScraperListener l)

		listeners.removeListener(l);
	
public TRTrackerScraperResponsescrape(TOTorrent torrent)

		return( scrape( torrent, false ));
	
public TRTrackerScraperResponsescrape(TOTorrent torrent, java.net.URL target_url)

		return( scrape( torrent, target_url, false ));
	
public TRTrackerScraperResponsescrape(TOTorrent torrent, boolean force)

		return( scrape( torrent, null, force ));
	
public TRTrackerScraperResponsescrape(TOTorrent torrent, java.net.URL target_url, boolean force)

		if (torrent == null ){
			
			return null;
		}

		if ( TorrentUtils.isDecentralised( torrent )){
			
			return( dht_scraper.scrape( torrent, target_url, force ));
			
		}else{
			
			return( bt_scraper.scrape( torrent, target_url, force ));
		}
	
public TRTrackerScraperResponsescrape(TRTrackerAnnouncer tracker_client)

		TOTorrent	torrent = tracker_client.getTorrent();

		if ( TorrentUtils.isDecentralised( torrent )){

			return( dht_scraper.scrape( tracker_client ));
			
		}else{
			
			return( bt_scraper.scrape( tracker_client ));
		}
	
public voidscrapeReceived(TRTrackerScraperResponse response)

		listeners.dispatch( LDT_SCRAPE_RECEIVED, response );
	
public voidsetClientResolver(TRTrackerScraperClientResolver resolver)

		client_resolver	= resolver;
	
public voidsetScrape(TOTorrent torrent, java.net.URL url, org.gudy.azureus2.plugins.download.DownloadScrapeResult result)

		if ( torrent != null ){
		
			if ( TorrentUtils.isDecentralised( torrent )){
				
				dht_scraper.setScrape( torrent, url, result );
				
			}else{
				
				bt_scraper.setScrape( torrent, url, result );
			}
		}