Methods Summary |
---|
public void | addListener(org.gudy.azureus2.plugins.PluginConfigListener l)
COConfigurationManager.addListener(
new COConfigurationListener()
{
public void
configurationSaved()
{
l.configSaved();
}
});
|
public boolean | getBooleanParameter(java.lang.String name)
return getDefaultedBooleanParameter(name, true);
|
public boolean | getBooleanParameter(java.lang.String name, boolean default_value)
return getBooleanParameter(name, default_value, true, false);
|
private boolean | getBooleanParameter(java.lang.String name, boolean _default, boolean map_name, boolean set_default)
Object obj = getFakeValueWhenDisabled(key,name);
if ( obj != null ){
return(((Boolean)obj).booleanValue());
}
if (map_name) {name = mapKeyName(name, false);}
if (set_default) {COConfigurationManager.setBooleanDefault(name, _default);}
else if (!hasParameter(name)) {return _default;}
return COConfigurationManager.getBooleanParameter(name);
|
public byte[] | getByteParameter(java.lang.String name)
return getDefaultedByteParameter(name, true);
|
public byte[] | getByteParameter(java.lang.String name, byte[] default_value)
return getByteParameter(name, default_value, true, false);
|
private byte[] | getByteParameter(java.lang.String name, byte[] _default, boolean map_name, boolean set_default)
Object obj = getFakeValueWhenDisabled(key,name);
if ( obj != null ){
return((byte[])obj);
}
if (map_name) {name = mapKeyName(name, false);}
if (set_default) {COConfigurationManager.setByteDefault(name, _default);}
else if (!hasParameter(name)) {return _default;}
return COConfigurationManager.getByteParameter(name);
|
private boolean | getDefaultedBooleanParameter(java.lang.String name, boolean map_name)
Object obj = getFakeValueWhenDisabled(key,name);
if ( obj != null ){
return(((Boolean)obj).booleanValue());
}
return getBooleanParameter(name, ConfigurationDefaults.def_boolean == 1, map_name, false);
|
private byte[] | getDefaultedByteParameter(java.lang.String name, boolean map_name)
return getByteParameter(name, ConfigurationDefaults.def_bytes, map_name, false);
|
private float | getDefaultedFloatParameter(java.lang.String name, boolean map_name)
return getFloatParameter(name, ConfigurationDefaults.def_float, map_name, false);
|
private int | getDefaultedIntParameter(java.lang.String name, boolean map_name)
return getIntParameter(name, ConfigurationDefaults.def_int, map_name, false);
|
private long | getDefaultedLongParameter(java.lang.String name, boolean map_name)
return getLongParameter(name, ConfigurationDefaults.def_long, map_name, false);
|
private java.lang.String | getDefaultedStringParameter(java.lang.String name, boolean map_name)
return getStringParameter(name, ConfigurationDefaults.def_String, map_name, false);
|
private static java.lang.Object | getFakeValueWhenDisabled(java.lang.String key, java.lang.String name)
if ( name.startsWith(key)){
return( null );
}
synchronized( PluginConfigImpl.class ){
if ( fake_values_when_disabled != null ){
return( fake_values_when_disabled.get( name ));
}
}
return( null );
|
private float | getFloatParameter(java.lang.String name, float _default, boolean map_name, boolean set_default)
Object obj = getFakeValueWhenDisabled(key,name);
if ( obj != null ){
return(((Float)obj).floatValue());
}
if (map_name) {name = mapKeyName(name, false);}
if (set_default) {COConfigurationManager.setFloatDefault(name, _default);}
else if (!hasParameter(name)) {return _default;}
return COConfigurationManager.getFloatParameter(name);
|
public float | getFloatParameter(java.lang.String name)
return getDefaultedFloatParameter(name, true);
|
public float | getFloatParameter(java.lang.String name, float default_value)
return getFloatParameter(name, default_value, true, false);
|
private int | getIntParameter(java.lang.String name, int _default, boolean map_name, boolean set_default)
Object obj = getFakeValueWhenDisabled(key,name);
if ( obj != null ){
return(((Long)obj).intValue());
}
if (map_name) {name = mapKeyName(name, false);}
if (set_default) {COConfigurationManager.setIntDefault(name, _default);}
else if (!hasParameter(name)) {return _default;}
return COConfigurationManager.getIntParameter(name);
|
public int | getIntParameter(java.lang.String name)
return getDefaultedIntParameter(name, true);
|
public int | getIntParameter(java.lang.String name, int default_value)
return getIntParameter(name, default_value, true, false);
|
private long | getLongParameter(java.lang.String name, long _default, boolean map_name, boolean set_default)
Object obj = getFakeValueWhenDisabled(key,name);
if ( obj != null ){
return(((Long)obj).longValue());
}
if (map_name) {name = mapKeyName(name, false);}
if (set_default) {COConfigurationManager.setLongDefault(name, _default);}
else if (!hasParameter(name)) {return _default;}
return COConfigurationManager.getLongParameter(name);
|
public long | getLongParameter(java.lang.String name)
return getDefaultedLongParameter(name, true);
|
public long | getLongParameter(java.lang.String name, long default_value)
return getLongParameter(name, default_value, true, false);
|
public org.gudy.azureus2.plugins.config.ConfigParameter | getParameter(java.lang.String key)
return( new ConfigParameterImpl( mapKeyName(key, false)));
|
public boolean | getPluginBooleanParameter(java.lang.String name)
return getDefaultedBooleanParameter(this.key + name, false);
|
public boolean | getPluginBooleanParameter(java.lang.String name, boolean default_value)
return getBooleanParameter(this.key + name, default_value, false, true);
|
public byte[] | getPluginByteParameter(java.lang.String name)
return getDefaultedByteParameter(this.key + name, false);
|
public byte[] | getPluginByteParameter(java.lang.String name, byte[] default_value)
return getByteParameter(this.key + name, default_value, false, true);
|
public java.lang.String | getPluginConfigKeyPrefix()
return( key );
|
public float | getPluginFloatParameter(java.lang.String name)
return getDefaultedFloatParameter(this.key + name, false);
|
public float | getPluginFloatParameter(java.lang.String name, float default_value)
return getFloatParameter(this.key + name, default_value, false, true);
|
public int | getPluginIntParameter(java.lang.String name)
return getDefaultedIntParameter(this.key + name, false);
|
public int | getPluginIntParameter(java.lang.String name, int default_value)
return getIntParameter(this.key + name, default_value, false, true);
|
public java.util.List | getPluginListParameter(java.lang.String key, java.util.List default_value)
return COConfigurationManager.getListParameter(this.key+key, default_value);
|
public long | getPluginLongParameter(java.lang.String name)
return getDefaultedLongParameter(this.key + name, false);
|
public long | getPluginLongParameter(java.lang.String name, long default_value)
return getLongParameter(this.key + name, default_value, false, true);
|
public java.util.Map | getPluginMapParameter(java.lang.String key, java.util.Map default_value)
return COConfigurationManager.getMapParameter(this.key+key, default_value);
|
public org.gudy.azureus2.plugins.config.ConfigParameter | getPluginParameter(java.lang.String key)
return( new ConfigParameterImpl( this.key+key ));
|
public java.lang.String | getPluginStringParameter(java.lang.String name)
return getDefaultedStringParameter(this.key + name, false);
|
public java.lang.String | getPluginStringParameter(java.lang.String name, java.lang.String default_value)
return getStringParameter(this.key + name, default_value, false, true);
|
public java.io.File | getPluginUserFile(java.lang.String name)
String dir = plugin_interface.getUtilities().getAzureusUserDir();
File file = new File( dir, "plugins" );
String p_dir = plugin_interface.getPluginDirectoryName();
if ( p_dir.length() != 0 ){
int lp = p_dir.lastIndexOf(File.separatorChar);
if ( lp != -1 ){
p_dir = p_dir.substring(lp+1);
}
file = new File( file, p_dir );
}else{
String id = plugin_interface.getPluginID();
if ( id.length() > 0 && !id.equals( PluginInitializer.INTERNAL_PLUGIN_ID )){
file = new File( file, id );
}else{
throw( new RuntimeException( "Plugin was not loaded from a directory" ));
}
}
FileUtil.mkdirs(file);
return( new File( file, name ));
|
private java.lang.String | getStringParameter(java.lang.String name, java.lang.String _default, boolean map_name, boolean set_default)
Object obj = getFakeValueWhenDisabled(key,name);
if ( obj != null ){
return((String)obj);
}
if (map_name) {name = mapKeyName(name, false);}
if (set_default) {COConfigurationManager.setStringDefault(name, _default);}
else if (!hasParameter(name)) {return _default;}
return COConfigurationManager.getStringParameter(name);
|
public java.lang.String | getStringParameter(java.lang.String name)
return getDefaultedStringParameter(name, true);
|
public java.lang.String | getStringParameter(java.lang.String name, java.lang.String default_value)
return getStringParameter(name, default_value, true, false);
|
public boolean | getUnsafeBooleanParameter(java.lang.String name)
return getDefaultedBooleanParameter(name, false);
|
public boolean | getUnsafeBooleanParameter(java.lang.String name, boolean default_value)
return getBooleanParameter(name, default_value, false, false);
|
public byte[] | getUnsafeByteParameter(java.lang.String name)
return getDefaultedByteParameter(name, false);
|
public byte[] | getUnsafeByteParameter(java.lang.String name, byte[] default_value)
return getByteParameter(name, default_value, false, false);
|
public float | getUnsafeFloatParameter(java.lang.String name)
return getDefaultedFloatParameter(name, false);
|
public float | getUnsafeFloatParameter(java.lang.String name, float default_value)
return getFloatParameter(name, default_value, false, false);
|
public int | getUnsafeIntParameter(java.lang.String name)
return getDefaultedIntParameter(name, false);
|
public int | getUnsafeIntParameter(java.lang.String name, int default_value)
return getIntParameter(name, default_value, false, false);
|
public long | getUnsafeLongParameter(java.lang.String name)
return getDefaultedLongParameter(name, false);
|
public long | getUnsafeLongParameter(java.lang.String name, long default_value)
return getLongParameter(name, default_value, false, false);
|
public java.util.Map | getUnsafeParameterList()
Set params = COConfigurationManager.getAllowedParameters();
Iterator it = params.iterator();
Map result = new HashMap();
while( it.hasNext()){
try{
String name = (String)it.next();
Object val = COConfigurationManager.getParameter( name );
if ( val instanceof String || val instanceof Long ){
}else if ( val instanceof byte[]){
val = new String((byte[])val, "UTF-8" );
}else if ( val instanceof Integer ){
val = new Long(((Integer)val).intValue());
}else if ( val instanceof List ){
val = null;
}else if ( val instanceof Map ){
val = null;
}else if ( val instanceof Boolean ){
val = new Long(((Boolean)val).booleanValue()?1:0);
}else if ( val instanceof Float || val instanceof Double ){
val = val.toString();
}
if ( val != null ){
result.put( name, val );
}
}catch( Throwable e ){
Debug.printStackTrace(e);
}
}
return( result );
|
public java.lang.String | getUnsafeStringParameter(java.lang.String name)
return getDefaultedStringParameter(name, false);
|
public java.lang.String | getUnsafeStringParameter(java.lang.String name, java.lang.String default_value)
return getStringParameter(name, default_value, false, false);
|
public boolean | hasParameter(java.lang.String param_name)
// Don't see any reason why a plugin should care whether it is looking
// at a system default setting or not, so we'll do an implicit check.
return COConfigurationManager.hasParameter(param_name, false);
|
public boolean | hasPluginParameter(java.lang.String param_name)
// We should not have default settings for plugins in configuration
// defaults, so we don't bother doing an implicit check.
return COConfigurationManager.hasParameter(this.key + param_name, true);
|
public boolean | isNewInstall()
return( COConfigurationManager.isNewInstall());
|
private java.lang.String | mapKeyName(java.lang.String key, boolean for_set)
String result = (String)external_to_internal_key_map.get(key);
if (result == null) {
if (for_set) {
throw new RuntimeException("No permission to set the value of core parameter: " + key);
}
else {
return key;
}
}
return result;
|
public boolean | removePluginParameter(java.lang.String key)
return COConfigurationManager.removeParameter(this.key + key);
|
public void | save()
COConfigurationManager.save();
|
public void | setBooleanParameter(java.lang.String name, boolean value)
if ( setFakeValueWhenDisabled(key, name, new Boolean( value))){
return;
}
COConfigurationManager.setParameter(mapKeyName(name, true), value);
|
public void | setByteParameter(java.lang.String name, byte[] value)
if ( setFakeValueWhenDisabled(key, name, value )){
return;
}
COConfigurationManager.setParameter(mapKeyName(name, true), value);
|
public static void | setEnablePluginCoreConfigChange(boolean enabled)
synchronized( PluginConfigImpl.class ){
if ( enabled ){
fake_values_ref_count--;
if ( fake_values_ref_count == 0 ){
// TODO: we could try and recover the faked values at this point
fake_values_when_disabled = null;
}
}else{
fake_values_ref_count++;
if ( fake_values_ref_count == 1 ){
fake_values_when_disabled = new HashMap();
}
}
}
|
private static boolean | setFakeValueWhenDisabled(java.lang.String key, java.lang.String name, java.lang.Object value)
if ( name.startsWith(key)){
return( false );
}
synchronized( PluginConfigImpl.class ){
if ( fake_values_when_disabled != null ){
fake_values_when_disabled.put( name, value );
return( true );
}
}
return( false );
|
public void | setFloatParameter(java.lang.String name, float value)
if ( setFakeValueWhenDisabled(key, name, new Float( value))){
return;
}
COConfigurationManager.setParameter(mapKeyName(name, true), value);
|
public void | setIntParameter(java.lang.String name, int value)
if ( setFakeValueWhenDisabled(key, name, new Long( value))){
return;
}
COConfigurationManager.setParameter(mapKeyName(name, true), value);
|
public void | setLongParameter(java.lang.String name, long value)
if ( setFakeValueWhenDisabled(key, name, new Long( value))){
return;
}
COConfigurationManager.setParameter(mapKeyName(name, true), value);
|
public void | setPluginConfigKeyPrefix(java.lang.String _key)
if (_key.length() > 0 || plugin_interface.isBuiltIn()) {
key = _key;
} else {
throw (new RuntimeException("Can't set Plugin Config Key Prefix to '"
+ _key + "'"));
}
|
public void | setPluginListParameter(java.lang.String key, java.util.List value)
COConfigurationManager.setParameter(this.key+key, value);
|
public void | setPluginMapParameter(java.lang.String key, java.util.Map value)
COConfigurationManager.setParameter(this.key+key, value);
|
public void | setPluginParameter(java.lang.String name, boolean value)
COConfigurationManager.setParameter(this.key + name, value);
|
public void | setPluginParameter(java.lang.String name, byte[] value)
COConfigurationManager.setParameter(this.key + name, value);
|
public void | setPluginParameter(java.lang.String name, float value)
COConfigurationManager.setParameter(this.key + name, value);
|
public void | setPluginParameter(java.lang.String name, int value)
COConfigurationManager.setParameter(this.key + name, value);
|
public void | setPluginParameter(java.lang.String name, long value)
COConfigurationManager.setParameter(this.key + name, value);
|
public void | setPluginParameter(java.lang.String name, java.lang.String value)
COConfigurationManager.setParameter(this.key + name, value);
|
public void | setPluginParameter(java.lang.String key, int value, boolean global)
COConfigurationManager.setParameter(this.key+key, value);
if (global) {
MagnetURIHandler.getSingleton().addInfo(this.key+key, value);
}
|
public void | setStringParameter(java.lang.String name, java.lang.String value)
if ( setFakeValueWhenDisabled(key, name, value)){
return;
}
COConfigurationManager.setParameter(mapKeyName(name, true), value);
|
public void | setUnsafeBooleanParameter(java.lang.String name, boolean value)
if ( setFakeValueWhenDisabled(key, name, new Boolean( value))){
return;
}
COConfigurationManager.setParameter(name, value);
|
public void | setUnsafeByteParameter(java.lang.String name, byte[] value)
if ( setFakeValueWhenDisabled(key, name, value)){
return;
}
COConfigurationManager.setParameter(name, value);
|
public void | setUnsafeFloatParameter(java.lang.String name, float value)
if ( setFakeValueWhenDisabled(key, name, new Float( value))){
return;
}
COConfigurationManager.setParameter(name, value);
|
public void | setUnsafeIntParameter(java.lang.String name, int value)
if ( setFakeValueWhenDisabled(key, name, new Long( value))){
return;
}
COConfigurationManager.setParameter(name, value);
|
public void | setUnsafeLongParameter(java.lang.String name, long value)
if ( setFakeValueWhenDisabled(key, name, new Long( value))){
return;
}
COConfigurationManager.setParameter(name, value);
|
public void | setUnsafeStringParameter(java.lang.String name, java.lang.String value)
if ( setFakeValueWhenDisabled(key, name, value )){
return;
}
COConfigurationManager.setParameter(name, value);
|