add int getProperty(String prop, int default)

This commit is contained in:
zzz
2008-12-10 16:32:26 +00:00
parent d16f187394
commit 0956393cf3
2 changed files with 36 additions and 0 deletions

View File

@@ -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

View File

@@ -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.