FileDocCategorySizeDatePackage
COConfigurationManager.javaAPI DocAzureus 3.0.3.413460Tue Jun 05 00:26:40 BST 2007org.gudy.azureus2.core3.config

COConfigurationManager

public class COConfigurationManager extends Object

Fields Summary
public static final int
CONFIG_DEFAULT_MIN_MAX_UPLOAD_SPEED
public static final int
CONFIG_DEFAULT_MAX_DOWNLOAD_SPEED
public static final int
CONFIG_DEFAULT_MAX_CONNECTIONS_PER_TORRENT
public static final int
CONFIG_DEFAULT_MAX_CONNECTIONS_GLOBAL
public static final int
CONFIG_CACHE_SIZE_MAX_MB
public static final boolean
ENABLE_MULTIPLE_UDP_PORTS
private static boolean
pre_initialised
Constructors Summary
Methods Summary
public static voidaddAndFireParameterListener(java.lang.String parameter, ParameterListener listener)

	  ConfigurationManager.getInstance().addParameterListener(parameter, listener);
	  
	  listener.parameterChanged( parameter );
	
public static voidaddAndFireParameterListeners(java.lang.String[] parameters, ParameterListener listener)

		for (int i=0;i<parameters.length;i++){
			ConfigurationManager.getInstance().addParameterListener(parameters[i], listener);
		}
	  
		listener.parameterChanged( null );
	
public static voidaddListener(COConfigurationListener listener)

		ConfigurationManager.getInstance().addListener( listener );
	
public static voidaddParameterListener(java.lang.String parameter, ParameterListener listener)

	  ConfigurationManager.getInstance().addParameterListener(parameter, listener);
	
public static voidaddParameterListener(java.lang.String[] ids, ParameterListener listener)

param
strings
param
parameterListener
since
3.0.1.5

		ConfigurationManager instance = ConfigurationManager.getInstance();
		for (int i = 0; i < ids.length; i++) {
		  instance.addParameterListener(ids[i], listener);
		}
	
public static booleandoesParameterDefaultExist(java.lang.String parameter)
checks if a default is defined for the named parameter

param
parameter
return

       return ConfigurationDefaults.getInstance().doesParameterDefaultExist(parameter);
  
public static booleandoesParameterNonDefaultExist(java.lang.String parameter)
checks if the user has explicitly set a value for the named parameter

param
parameter
return

       return ConfigurationManager.getInstance().doesParameterNonDefaultExist(parameter);
  
public static java.util.SetgetAllowedParameters()

  	return ConfigurationDefaults.getInstance().getAllowedParameters();
  
public static booleangetBooleanParameter(java.lang.String _name, boolean _default)

deprecated
You should set ConfigurationDefaults, and use {@link #getBooleanParameter(String)}

		return( ConfigurationManager.getInstance().getBooleanParameter( _name, _default ));
	
public static booleangetBooleanParameter(java.lang.String _name)

		return( ConfigurationManager.getInstance().getBooleanParameter( _name ));
	
public static byte[]getByteParameter(java.lang.String _name)

		return( ConfigurationManager.getInstance().getByteParameter(_name));
	
public static byte[]getByteParameter(java.lang.String _name, byte[] _default)

		return( ConfigurationManager.getInstance().getByteParameter( _name, _default ));
	
public static java.lang.ObjectgetDefault(java.lang.String parameter)

	return( ConfigurationDefaults.getInstance().getParameter( parameter ));
  
public static java.lang.StringgetDirectoryParameter(java.lang.String _name)

		return( ConfigurationManager.getInstance().getDirectoryParameter( _name ));
	
public static floatgetFloatParameter(java.lang.String _name)

		return( ConfigurationManager.getInstance().getFloatParameter( _name ));
	
public static floatgetFloatParameter(java.lang.String _name, float _def)

		return( ConfigurationManager.getInstance().getFloatParameter( _name, _def ));
	
public static intgetIntParameter(java.lang.String _name)

		return( ConfigurationManager.getInstance().getIntParameter( _name ));
	
public static intgetIntParameter(java.lang.String _name, int _default)
Only use this for internal values, NOT for ones that the user can sensibly change. In this case add the key to the configuration defaults and use the above method

param
_name
param
_def
return

		return( ConfigurationManager.getInstance().getIntParameter( _name, _default ));
	
public static java.util.ListgetListParameter(java.lang.String parameter, java.util.List def)

		return( ConfigurationManager.getInstance().getListParameter( parameter, def ));
	
public static longgetLongParameter(java.lang.String _name)

		return( ConfigurationManager.getInstance().getLongParameter( _name ));
	
public static longgetLongParameter(java.lang.String _name, long _def)
Only use this for internal values, NOT for ones that the user can sensibly change. In this case add the key to the configuration defaults and use the above method

param
_name
param
_def
return

		return( ConfigurationManager.getInstance().getLongParameter( _name, _def ));
	
public static java.util.MapgetMapParameter(java.lang.String parameter, java.util.Map def)

		return( ConfigurationManager.getInstance().getMapParameter( parameter, def ));
	
public static java.lang.ObjectgetParameter(java.lang.String name)
raw parameter access

param
name
return

  	return ConfigurationManager.getInstance().getParameter(name);
  
public static StringListgetStringListParameter(java.lang.String parameter)

		return( ConfigurationManager.getInstance().getStringListParameter( parameter ));
	
public static java.lang.StringgetStringParameter(java.lang.String _name)

		return( ConfigurationManager.getInstance().getStringParameter( _name ));
	
public static java.lang.StringgetStringParameter(java.lang.String _name, java.lang.String _default)

		return( ConfigurationManager.getInstance().getStringParameter( _name, _default ));
	
public static booleanhasParameter(java.lang.String parameter, boolean explicit)
Returns true if a parameter with the given name exists.

param
key The name of the parameter to check.
param
explicit If true, we only check for a value which is definitely stored explicitly, false means that we'll also check against configuration defaults too.

		return ConfigurationManager.getInstance().hasParameter(parameter, explicit);
	
public static ConfigurationManagerinitialise()

		preInitialise();
		
		return ConfigurationManager.getInstance();
	
public static ConfigurationManagerinitialiseFromMap(java.util.Map data)

		preInitialise();
		
		return ConfigurationManager.getInstance(data);
	
public static final booleanisNewInstall()

		return( ConfigurationManager.getInstance().isNewInstall());
	
public static synchronized voidpreInitialise()

	
	   
	
		  	
		if ( !pre_initialised ){
			
			pre_initialised	= true;
		
			try{
			  	String	handlers = System.getProperty( "java.protocol.handler.pkgs" );
			  	
			  	if ( handlers == null ){
			  		
			  		handlers = "org.gudy.azureus2.core3.util.protocol";
			  		
			  	}else{
			  		
			  		handlers += "|org.gudy.azureus2.core3.util.protocol";
			  	}
			  	
			  	System.setProperty( "java.protocol.handler.pkgs", handlers );
			  	 	
			  		// DNS cache timeouts
			  	
			  	System.setProperty("sun.net.inetaddr.ttl", "60");
			  	System.setProperty("networkaddress.cache.ttl", "60");
		      
			  		// defaults, overridden later if needed
		      
			  	System.setProperty( "sun.net.client.defaultConnectTimeout", "120000" );	
			  	System.setProperty(	"sun.net.client.defaultReadTimeout", "60000" ); 
			  			
			      //see http://developer.apple.com/releasenotes/Java/Java142RN/ResolvedIssues/chapter_3_section_7.html
			      //fixes the osx kernel panic bug caused by Apple's faulty kqueue implementation (as of 10.3.6)
			  	
			    if( Constants.isOSX ) {
			        System.setProperty( "java.nio.preferSelect", "true" );
			    }
			}catch( Throwable e ){
				
					// can happen in applet
				
				e.printStackTrace();
			}
		}
	
public static voidregisterExternalDefaults(java.util.Map addmap)

  	ConfigurationDefaults.getInstance().registerExternalDefaults(addmap);
  
public static voidremoveListener(COConfigurationListener listener)

		ConfigurationManager.getInstance().removeListener( listener );
	
public static booleanremoveParameter(java.lang.String parameter)

		return ConfigurationManager.getInstance().removeParameter(parameter);
	
public static voidremoveParameterListener(java.lang.String parameter, ParameterListener listener)

		ConfigurationManager.getInstance().removeParameterListener(parameter, listener);
	
public static voidsave()

		ConfigurationManager.getInstance().save();
	
public static voidsetBooleanDefault(java.lang.String parameter, boolean _default)

  	ConfigurationDefaults.getInstance().addParameter( parameter, _default );
  
public static voidsetByteDefault(java.lang.String parameter, byte[] _default)

  	ConfigurationDefaults.getInstance().addParameter( parameter, _default );
  
public static voidsetDirty()
Mark as needing a save but not immediately - use when potentially needing a large number of saves that aren't absolutely required to be immediately persisted

		ConfigurationManager.getInstance().setDirty();
	
public static voidsetFloatDefault(java.lang.String parameter, float _default)

	  ConfigurationDefaults.getInstance().addParameter( parameter, _default );
  
public static voidsetIntDefault(java.lang.String parameter, int _default)

  	ConfigurationDefaults.getInstance().addParameter( parameter, _default );
  
public static voidsetLongDefault(java.lang.String parameter, long _default)

  	ConfigurationDefaults.getInstance().addParameter( parameter, _default );
  
public static booleansetParameter(java.lang.String parameter, boolean value)

		return ConfigurationManager.getInstance().setParameter( parameter, value );
	
public static booleansetParameter(java.lang.String parameter, int value)

		return ConfigurationManager.getInstance().setParameter( parameter, value );
	
public static booleansetParameter(java.lang.String parameter, long value)

		return ConfigurationManager.getInstance().setParameter( parameter, value );
	
public static booleansetParameter(java.lang.String parameter, byte[] value)

		return ConfigurationManager.getInstance().setParameter( parameter, value );
	
public static booleansetParameter(java.lang.String parameter, float value)

		return ConfigurationManager.getInstance().setParameter( parameter, value );
	
public static booleansetParameter(java.lang.String parameter, StringList value)

		return ConfigurationManager.getInstance().setParameter( parameter, value );
	
public static booleansetParameter(java.lang.String parameter, java.util.List value)

		return ConfigurationManager.getInstance().setParameter( parameter, value );
	
public static booleansetParameter(java.lang.String parameter, java.util.Map value)

		return ConfigurationManager.getInstance().setParameter( parameter, value );
	
public static booleansetParameter(java.lang.String parameter, java.lang.String value)

		return ConfigurationManager.getInstance().setParameter( parameter, value );
	
public static booleansetRGBParameter(java.lang.String parameter, int red, int green, int blue)

		return ConfigurationManager.getInstance().setRGBParameter( parameter, red, green, blue);
	
public static voidsetStringDefault(java.lang.String parameter, java.lang.String _default)

  	ConfigurationDefaults.getInstance().addParameter( parameter, _default );
  
public static booleanverifyParameter(java.lang.String parameter, java.lang.String value)

		return ConfigurationManager.getInstance().verifyParameter( parameter, value );