FileDocCategorySizeDatePackage
CategoryImpl.javaAPI DocAzureus 3.0.3.45200Tue Feb 06 21:43:42 GMT 2007org.gudy.azureus2.core3.category.impl

CategoryImpl

public class CategoryImpl extends Object implements Comparable, org.gudy.azureus2.core3.category.Category

Fields Summary
private String
sName
private int
type
private List
managers
private int
upload_speed
private int
download_speed
private com.aelitis.azureus.core.networkmanager.LimitedRateGroup
upload_limiter
private com.aelitis.azureus.core.networkmanager.LimitedRateGroup
download_limiter
private static final int
LDT_CATEGORY_DMADDED
private static final int
LDT_CATEGORY_DMREMOVED
private org.gudy.azureus2.core3.util.ListenerManager
category_listeners
Constructors Summary
public CategoryImpl(String sName, int maxup, int maxdown)


          
    this.sName = sName;
    this.type = Category.TYPE_USER;
    upload_speed	= maxup;
    download_speed	= maxdown;
  
public CategoryImpl(String sName, int type)

    this.sName = sName;
    this.type = type;
  
Methods Summary
public voidaddCategoryListener(org.gudy.azureus2.core3.category.CategoryListener l)

		category_listeners.addListener( l );
	
public voidaddManager(DownloadManagerState manager_state)

    if (manager_state.getCategory() != this) {
    	manager_state.setCategory(this);
      // we will be called again by CategoryManager.categoryChange
      return;
    }
    
    DownloadManager	manager = manager_state.getDownloadManager();
    
    if (!managers.contains(manager)) {
      managers.add(manager);
      
      manager.addRateLimiter( upload_limiter, true );
      manager.addRateLimiter( download_limiter, false );
      
      category_listeners.dispatch(LDT_CATEGORY_DMADDED, manager);
    }
  
public intcompareTo(java.lang.Object b)

    boolean aTypeIsUser = type == Category.TYPE_USER;
    boolean bTypeIsUser = ((Category)b).getType() == Category.TYPE_USER;
    if (aTypeIsUser == bTypeIsUser)
      return sName.compareToIgnoreCase(((Category)b).getName());
    if (aTypeIsUser)
      return 1;
    return -1;
  
public java.util.ListgetDownloadManagers()

    return managers;
  
public intgetDownloadSpeed()

	  return( download_speed );
  
public java.lang.StringgetName()

    return sName;
  
public intgetType()

    return type;
  
public intgetUploadSpeed()

	  return( upload_speed );
  
public voidremoveCategoryListener(org.gudy.azureus2.core3.category.CategoryListener l)

		category_listeners.removeListener( l );
	
public voidremoveManager(DownloadManagerState manager_state)

    if (manager_state.getCategory() == this) {
    	manager_state.setCategory(null);
      // we will be called again by CategoryManager.categoryChange
      return;
    }
    DownloadManager	manager = manager_state.getDownloadManager();

    if (managers.contains(manager) || type != Category.TYPE_USER) {
      managers.remove(manager);
      
      manager.removeRateLimiter( upload_limiter, true );
      manager.removeRateLimiter( download_limiter, false );
 
      category_listeners.dispatch( LDT_CATEGORY_DMREMOVED, manager );
    }
  
public voidsetDownloadSpeed(int speed)

	  if ( download_speed != speed ){
		  
		  download_speed = speed;
		  
		  CategoryManagerImpl.getInstance().saveCategories();
	  }
  
public voidsetUploadSpeed(int speed)

	  if ( upload_speed != speed ){
		  
		  upload_speed	= speed;
	  
		  CategoryManagerImpl.getInstance().saveCategories();
	  }