FileDocCategorySizeDatePackage
TorrentAttributeCategoryImpl.javaAPI DocAzureus 3.0.3.43582Sat Jul 22 16:21:34 BST 2006org.gudy.azureus2.pluginsimpl.local.torrent

TorrentAttributeCategoryImpl

public class TorrentAttributeCategoryImpl extends BaseTorrentAttributeImpl
author
parg

Fields Summary
Constructors Summary
protected TorrentAttributeCategoryImpl()

		CategoryManager.addCategoryManagerListener(
				new CategoryManagerListener()
				{
					public void
					categoryAdded(
						final Category category )
					{
						TorrentAttributeEvent	ev = 
							new TorrentAttributeEvent()
							{
								public int
								getType()
								{
									return( TorrentAttributeEvent.ET_ATTRIBUTE_VALUE_ADDED );
								}
							
								public TorrentAttribute
								getAttribute()
								{
									return( TorrentAttributeCategoryImpl.this );
								}
								
								public Object
								getData()
								{
									return( category.getName());
								}
							};
							
							TorrentAttributeCategoryImpl.this.notifyListeners(ev);
					}
						
					public void
					categoryRemoved(
						final Category category )
					{
						TorrentAttributeEvent	ev = 
							new TorrentAttributeEvent()
							{
								public int
								getType()
								{
									return( TorrentAttributeEvent.ET_ATTRIBUTE_VALUE_REMOVED );
								}
							
								public TorrentAttribute
								getAttribute()
								{
									return( TorrentAttributeCategoryImpl.this );
								}
								
								public Object
								getData()
								{
									return( category.getName());
								}
							};
							
							TorrentAttributeCategoryImpl.this.notifyListeners(ev);
					}
				});
	
Methods Summary
public voidaddDefinedValue(java.lang.String name)

		CategoryManager.createCategory( name );
	
public java.lang.String[]getDefinedValues()

		Category[] categories = CategoryManager.getCategories();
		
		List	v = new ArrayList();
		
		for (int i=0;i<categories.length;i++){
			
			Category cat = categories[i];
			
			if ( cat.getType() == Category.TYPE_USER ){
			
				v.add( cat.getName());
			}
		}
		
		String[]	res = new String[v.size()];
		
		v.toArray( res );
		
			// make it nice for clients
		
		Arrays.sort( res, StaticUtilities.getFormatters().getAlphanumericComparator( true ));
		
		return( res );
	
public java.lang.StringgetName()

		return( TA_CATEGORY );
	
public voidremoveDefinedValue(java.lang.String name)

		Category cat = CategoryManager.getCategory( name );
		
		if ( cat != null ){
			
			CategoryManager.removeCategory( cat );
		}