PropLoaderpublic class PropLoader extends Object Tool for load properties from environment or property object. |
Methods Summary |
---|
protected int | getIntProp(int valDefault, java.lang.String envVar, java.lang.String propsName, java.lang.String propVar)Load integer property value from environment or
from connections.prop.
When environment setting is defined, variable receives the value from it.
Else it is initialized from connections.prop.
int retValue;
String strVal = getProp("D", envVar, propsName, propVar);
try {
retValue = Integer.parseInt(strVal);
} catch (NumberFormatException nfe) { // save default value
retValue = valDefault;
}
return retValue;
| protected java.lang.String | getProp(java.lang.String valDefault, java.lang.String envVar, java.lang.String propsName, java.lang.String propVar)Load string property value from environment or
from connections.prop.
When environment setting is defined, variable receives the value from it.
Else it is initialized from connections.prop.
String retValue = System.getProperty(envVar);
if (retValue == null) { // get from properties
try {
Properties props = new Properties();
props.load(new FileInputStream(propsName));
retValue = props.getProperty(propVar);
if (retValue == null) { // get default value
retValue = valDefault;
}
} catch (IOException ioe) { // no properties
retValue = valDefault;
}
}
return retValue;
|
|