FileDocCategorySizeDatePackage
TorrentAnnounceURLListImpl.javaAPI DocAzureus 3.0.3.43558Mon Apr 26 13:21:32 BST 2004org.gudy.azureus2.pluginsimpl.local.torrent

TorrentAnnounceURLListImpl

public class TorrentAnnounceURLListImpl extends Object implements TorrentAnnounceURLList
author
parg

Fields Summary
protected TorrentImpl
torrent
Constructors Summary
protected TorrentAnnounceURLListImpl(TorrentImpl _torrent)

		torrent	= _torrent;
	
Methods Summary
public voidaddSet(java.net.URL[] urls)

		if ( setAlreadyExists( urls )){
			
			return;
		}
		
		TorrentUtils.announceGroupsInsertLast( torrent.getTorrent(), urls );
		
		updated();
	
public TorrentAnnounceURLListSetcreate(java.net.URL[] urls)

		return( new TorrentAnnounceURLListSetImpl( this, torrent.getTorrent().getAnnounceURLGroup().createAnnounceURLSet(urls)));
	
public TorrentAnnounceURLListSet[]getSets()

		TOTorrentAnnounceURLGroup	group = torrent.getTorrent().getAnnounceURLGroup();
		
		TOTorrentAnnounceURLSet[]	sets = group.getAnnounceURLSets();
		
		TorrentAnnounceURLListSet[]	res = new TorrentAnnounceURLListSet[sets.length];
		
		for (int i=0;i<res.length;i++){
			
			res[i] = new TorrentAnnounceURLListSetImpl( this, sets[i]);
		}
		
		return( res );
	
public voidinsertSetAtFront(java.net.URL[] urls)

		if ( setAlreadyExists( urls )){
			
			return;
		}
		
		TorrentUtils.announceGroupsInsertFirst( torrent.getTorrent(), urls );
		
		updated();
	
protected booleansetAlreadyExists(java.net.URL[] urls)

		TOTorrentAnnounceURLGroup	group = torrent.getTorrent().getAnnounceURLGroup();
		
		TOTorrentAnnounceURLSet[]	sets = group.getAnnounceURLSets();

		for (int i=0;i<sets.length;i++){
			
			URL[]	u = sets[i].getAnnounceURLs();
			
			if ( u.length != urls.length ){
				
				continue;
			}
			
			boolean	all_found = true;
			
			for (int j=0;j<urls.length;j++){
				
				URL	u1 = urls[j];
				
				boolean	this_found = false;
				
				for ( int k=0;k<u.length;k++){
					
					URL	u2 = u[k];
					
					if ( u1.toString().equals( u2.toString())){
						
						this_found = true;
						
						break;
					}
				}
				
				if ( !this_found ){
					
					all_found = false;
					
					break;
				}
			}
			
			if ( all_found ){
				
				return( true );
			}
		}
		
		return( false );
	
public voidsetSets(TorrentAnnounceURLListSet[] sets)

		TOTorrentAnnounceURLGroup	group = torrent.getTorrent().getAnnounceURLGroup();
				
		TOTorrentAnnounceURLSet[]	res = new TOTorrentAnnounceURLSet[sets.length];
		
		for (int i=0;i<res.length;i++){
			
			res[i] = ((TorrentAnnounceURLListSetImpl)sets[i]).getSet();
		}
		
		group.setAnnounceURLSets( res );
		
		updated();
	
protected voidupdated()

		torrent.updated();