FileDocCategorySizeDatePackage
ParameterRepository.javaAPI DocAzureus 3.0.3.43869Mon Sep 20 07:38:12 BST 2004org.gudy.azureus2.pluginsimpl.local.ui.config

ParameterRepository

public class ParameterRepository extends Object
author
epall

Fields Summary
private static ParameterRepository
instance
private static org.gudy.azureus2.core3.util.AEMonitor
class_mon
private HashMap
params
Constructors Summary
private ParameterRepository()

	
	 
	
		params = new HashMap();
	
Methods Summary
public voidaddPlugin(Parameter[] parameters, java.lang.String displayName)

		params.put(displayName, parameters);
    
    // set the defaults
    ConfigurationDefaults def = ConfigurationDefaults.getInstance();
    if (def == null)
      return;

    for (int i = 0; i < parameters.length; i++) {
      Parameter parameter = parameters[i];
      if (!(parameter instanceof ParameterImpl))
        continue;
      String sKey = ((ParameterImpl)parameter).getKey();

      if(parameter instanceof StringParameterImpl) {
        def.addParameter(sKey,
                         ((StringParameterImpl)parameter).getDefaultValue());
      } else if(parameter instanceof IntParameterImpl) {
        def.addParameter(sKey,
                         ((IntParameterImpl)parameter).getDefaultValue());
      } else if(parameter instanceof BooleanParameterImpl) {
        def.addParameter(sKey,
                         ((BooleanParameterImpl)parameter).getDefaultValue());
      } else if(parameter instanceof FileParameter) {
        def.addParameter(sKey,
                         ((FileParameter)parameter).getDefaultValue());
      } else if(parameter instanceof DirectoryParameterImpl) {
        def.addParameter(sKey,
                         ((DirectoryParameterImpl)parameter).getDefaultValue());
      } else if(parameter instanceof IntsParameter) {
        def.addParameter(sKey,
                         ((IntsParameter)parameter).getDefaultValue());
      } else if(parameter instanceof StringListParameterImpl) {
        def.addParameter(sKey,
                         ((StringListParameterImpl)parameter).getDefaultValue());
      } else if(parameter instanceof ColorParameter) {
        def.addParameter(sKey + ".red",
                         ((ColorParameter)parameter).getDefaultRed());
        def.addParameter(sKey + ".green",
                         ((ColorParameter)parameter).getDefaultGreen());
        def.addParameter(sKey + ".blue",
                         ((ColorParameter)parameter).getDefaultBlue());
      }
    }
	
public static org.gudy.azureus2.pluginsimpl.local.ui.config.ParameterRepositorygetInstance()

		try{
			class_mon.enter();
		
			if(instance == null)
				instance = new ParameterRepository();
			return instance;
			
		}finally{
			
			class_mon.exit();
		}
	
public java.lang.String[]getNames()

	  Set keys = params.keySet();
	  return (String[])(keys.toArray(new String[keys.size()]));
	
public Parameter[]getParameterBlock(java.lang.String key)

	
		return (Parameter[])params.get(key);