forked from I2P_Developers/i2p.i2p
add int getProperty(String prop, int default)
This commit is contained in:
@@ -179,6 +179,25 @@ public class I2PAppContext {
|
||||
return System.getProperty(propName, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an int with an int default
|
||||
*/
|
||||
public int getProperty(String propName, int defaultVal) {
|
||||
String val = null;
|
||||
if (_overrideProps != null) {
|
||||
val = _overrideProps.getProperty(propName);
|
||||
if (val == null)
|
||||
val = System.getProperty(propName);
|
||||
}
|
||||
int ival = defaultVal;
|
||||
if (val != null) {
|
||||
try {
|
||||
ival = Integer.parseInt(val);
|
||||
} catch (NumberFormatException nfe) {}
|
||||
}
|
||||
return ival;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the configuration attributes of this context, listing the properties
|
||||
* provided during the context construction, as well as the ones included in
|
||||
|
@@ -329,6 +329,23 @@ public class RouterContext extends I2PAppContext {
|
||||
return super.getProperty(propName, defaultVal);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an int with an int default
|
||||
*/
|
||||
public int getProperty(String propName, int defaultVal) {
|
||||
if (_router != null) {
|
||||
String val = _router.getConfigSetting(propName);
|
||||
if (val != null) {
|
||||
int ival = defaultVal;
|
||||
try {
|
||||
ival = Integer.parseInt(val);
|
||||
} catch (NumberFormatException nfe) {}
|
||||
return ival;
|
||||
}
|
||||
}
|
||||
return super.getProperty(propName, defaultVal);
|
||||
}
|
||||
|
||||
/**
|
||||
* The context's synchronized clock, which is kept context specific only to
|
||||
* enable simulators to play with clock skew among different instances.
|
||||
|
Reference in New Issue
Block a user