⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 configurationmanager.java

📁 java 文件下载器。可自定义
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   ConfigurationManager.java

package org.gudy.azureus2.core3.config.impl;

import java.io.File;
import java.io.IOException;
import java.util.*;
import org.gudy.azureus2.core3.config.*;
import org.gudy.azureus2.core3.util.*;

// Referenced classes of package org.gudy.azureus2.core3.config.impl:
//			ConfigurationChecker, ConfigurationDefaults, ConfigurationParameterNotFoundException, StringListImpl

public class ConfigurationManager
	implements AEDiagnosticsEvidenceGenerator
{

	private static ConfigurationManager config_temp = null;
	private static ConfigurationManager config = null;
	private static AEMonitor class_mon = new AEMonitor("ConfigMan:class");
	private Map propertiesMap;
	private List transient_properties;
	private List listeners;
	private Hashtable parameterListeners;
	private AEMonitor this_mon;
	private static FrequencyLimitedDispatcher dirty_dispatcher = new FrequencyLimitedDispatcher(new AERunnable() {

		public void runSupport()
		{
			COConfigurationManager.save();
		}

	}, 30000);

	public static ConfigurationManager getInstance()
	{
		ConfigurationManager configurationmanager;
		class_mon.enter();
		if (config != null)
			break MISSING_BLOCK_LABEL_76;
		if (config_temp == null)
		{
			config_temp = new ConfigurationManager();
			config_temp.load();
			config_temp.initialise();
			config = config_temp;
			break MISSING_BLOCK_LABEL_76;
		}
		if (config_temp.propertiesMap == null)
			config_temp.load();
		configurationmanager = config_temp;
		class_mon.exit();
		return configurationmanager;
		configurationmanager = config;
		class_mon.exit();
		return configurationmanager;
		Exception exception;
		exception;
		class_mon.exit();
		throw exception;
	}

	public static ConfigurationManager getInstance(Map data)
	{
		ConfigurationManager configurationmanager;
		class_mon.enter();
		if (config == null)
			config = new ConfigurationManager(data);
		configurationmanager = config;
		class_mon.exit();
		return configurationmanager;
		Exception exception;
		exception;
		class_mon.exit();
		throw exception;
	}

	private ConfigurationManager()
	{
		transient_properties = new ArrayList();
		listeners = new ArrayList();
		parameterListeners = new Hashtable();
		this_mon = new AEMonitor("ConfigMan");
	}

	private ConfigurationManager(Map data)
	{
		transient_properties = new ArrayList();
		listeners = new ArrayList();
		parameterListeners = new Hashtable();
		this_mon = new AEMonitor("ConfigMan");
		if (data.get("Logger.DebugFiles.Enabled") == null)
			data.put("Logger.DebugFiles.Enabled", new Long(0L));
		propertiesMap = data;
	}

	protected void initialise()
	{
		ConfigurationChecker.checkConfiguration();
		ConfigurationChecker.setSystemProperties();
		AEDiagnostics.addEvidenceGenerator(this);
	}

	public void load(String filename)
	{
		Map data = FileUtil.readResilientConfigFile(filename, false);
		if (propertiesMap == null)
			propertiesMap = data;
	}

	public void load()
	{
		load("azureus.config");
	}

	public void save(String filename)
	{
		if (propertiesMap == null)
			return;
		TreeMap properties_clone = new TreeMap(propertiesMap);
		if (!transient_properties.isEmpty())
			properties_clone.keySet().removeAll(transient_properties);
		FileUtil.writeResilientConfigFile(filename, properties_clone);
		List listeners_copy;
		this_mon.enter();
		listeners_copy = new ArrayList(listeners);
		this_mon.exit();
		break MISSING_BLOCK_LABEL_92;
		Exception exception;
		exception;
		this_mon.exit();
		throw exception;
		for (int i = 0; i < listeners_copy.size(); i++)
		{
			COConfigurationListener l = (COConfigurationListener)listeners_copy.get(i);
			if (l != null)
				try
				{
					l.configurationSaved();
				}
				catch (Throwable e)
				{
					Debug.printStackTrace(e);
				}
			else
				Debug.out("COConfigurationListener is null");
		}

		return;
	}

	public void save()
	{
		save("azureus.config");
	}

	public void setDirty()
	{
		dirty_dispatcher.dispatch();
	}

	public boolean isNewInstall()
	{
		return ConfigurationChecker.isNewInstall();
	}

	public Set getDefinedParameters()
	{
		return propertiesMap.keySet();
	}

	public boolean getBooleanParameter(String parameter, boolean defaultValue)
	{
		int defaultInt = defaultValue ? 1 : 0;
		int result = getIntParameter(parameter, defaultInt);
		return result != 0;
	}

	public boolean getBooleanParameter(String parameter)
	{
		ConfigurationDefaults def = ConfigurationDefaults.getInstance();
		int result;
		try
		{
			result = getIntParameter(parameter, def.getIntParameter(parameter));
		}
		catch (ConfigurationParameterNotFoundException e)
		{
			result = getIntParameter(parameter, 0);
		}
		return result != 0;
	}

	public boolean setParameter(String parameter, boolean value)
	{
		return setParameter(parameter, value ? 1 : 0);
	}

	private Long getLongParameterRaw(String parameter)
	{
		return (Long)propertiesMap.get(parameter);
		Exception e;
		e;
		Debug.out((new StringBuilder()).append("Parameter '").append(parameter).append("' has incorrect type").toString(), e);
		return null;
	}

	public int getIntParameter(String parameter, int defaultValue)
	{
		Long tempValue = getLongParameterRaw(parameter);
		return tempValue == null ? defaultValue : tempValue.intValue();
	}

	public int getIntParameter(String parameter)
	{
		ConfigurationDefaults def = ConfigurationDefaults.getInstance();
		int result;
		try
		{
			result = getIntParameter(parameter, def.getIntParameter(parameter));
		}
		catch (ConfigurationParameterNotFoundException e)
		{
			result = getIntParameter(parameter, 0);
		}
		return result;
	}

	public long getLongParameter(String parameter, long defaultValue)
	{
		Long tempValue = getLongParameterRaw(parameter);
		return tempValue == null ? defaultValue : tempValue.longValue();
	}

	public long getLongParameter(String parameter)
	{
		ConfigurationDefaults def = ConfigurationDefaults.getInstance();
		long result;
		try
		{
			result = getLongParameter(parameter, def.getLongParameter(parameter));
		}
		catch (ConfigurationParameterNotFoundException e)
		{
			result = getLongParameter(parameter, 0L);
		}
		return result;
	}

	private byte[] getByteParameterRaw(String parameter)
	{
		return (byte[])(byte[])propertiesMap.get(parameter);
	}

	public byte[] getByteParameter(String parameter)
	{
		ConfigurationDefaults def = ConfigurationDefaults.getInstance();
		byte result[];
		try
		{
			result = getByteParameter(parameter, def.getByteParameter(parameter));
		}
		catch (ConfigurationParameterNotFoundException e)
		{
			result = getByteParameter(parameter, ConfigurationDefaults.def_bytes);
		}
		return result;
	}

	public byte[] getByteParameter(String parameter, byte defaultValue[])
	{
		byte tempValue[] = getByteParameterRaw(parameter);
		return tempValue == null ? defaultValue : tempValue;
	}

	private String getStringParameter(String parameter, byte defaultValue[])
	{
		byte bp[] = getByteParameter(parameter, defaultValue);
		if (bp == null)
			bp = getByteParameter(parameter, null);
		if (bp == null)
			return null;
		else
			return bytesToString(bp);
	}

	public String getStringParameter(String parameter, String defaultValue)
	{
		String tempValue = getStringParameter(parameter, (byte[])null);
		return tempValue == null ? defaultValue : tempValue;
	}

	public String getStringParameter(String parameter)
	{
		ConfigurationDefaults def = ConfigurationDefaults.getInstance();
		String result;
		try
		{
			result = getStringParameter(parameter, def.getStringParameter(parameter));
		}
		catch (ConfigurationParameterNotFoundException e)
		{
			result = getStringParameter(parameter, "");
		}
		return result;
	}

	public StringList getStringListParameter(String parameter)
	{
		List rawList = (List)propertiesMap.get(parameter);
		if (rawList == null)
			return new StringListImpl();
		return new StringListImpl(rawList);
		Exception e;
		e;
		Debug.out((new StringBuilder()).append("Parameter '").append(parameter).append("' has incorrect type").toString(), e);
		return new StringListImpl();
	}

	public boolean setParameter(String parameter, StringList value)
	{
		try
		{
			List encoded = new ArrayList();
			List l = ((StringListImpl)value).getList();
			for (int i = 0; i < l.size(); i++)
				encoded.add(stringToBytes((String)l.get(i)));

			propertiesMap.put(parameter, encoded);
			notifyParameterListeners(parameter);
		}
		catch (Exception e)
		{
			Debug.printStackTrace(e);
			return false;
		}
		return true;
	}

	public List getListParameter(String parameter, List def)
	{
		List rawList = (List)propertiesMap.get(parameter);
		if (rawList == null)
			return def;
		return rawList;
		Exception e;
		e;
		Debug.out((new StringBuilder()).append("Parameter '").append(parameter).append("' has incorrect type").toString(), e);
		return def;
	}

	public boolean setParameter(String parameter, List value)
	{
		try
		{
			propertiesMap.put(parameter, value);
			notifyParameterListeners(parameter);
		}
		catch (Exception e)
		{
			Debug.printStackTrace(e);
			return false;
		}
		return true;
	}

	public Map getMapParameter(String parameter, Map def)
	{
		Map map = (Map)propertiesMap.get(parameter);
		if (map == null)
			return def;
		return map;
		Exception e;
		e;
		Debug.out((new StringBuilder()).append("Parameter '").append(parameter).append("' has incorrect type").toString(), e);
		return def;
	}

	public boolean setParameter(String parameter, Map value)
	{
		try
		{
			propertiesMap.put(parameter, value);
			notifyParameterListeners(parameter);
		}
		catch (Exception e)
		{
			Debug.printStackTrace(e);
			return false;
		}
		return true;
	}

	public String getDirectoryParameter(String parameter)
		throws IOException
	{
		String dir = getStringParameter(parameter);
		if (dir.length() > 0)
		{

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -