/** * Retrieve boolean property value and if the value is not specified return the default value. * * @param prpSettings - properties to retrieve the setting from * @param strProperty - name of the property to retrieve * @param bDefaultValue - default value to use if a valid value is not specified. If null is * specified as a default value and no value is found then no config message will be printed * into log * @param strDisplayName - user friendly name of the property * @return boolean - value of the property or default value if the value is not specified */ public static Boolean getBooleanProperty( Properties prpSettings, String strProperty, Boolean bDefaultValue, String strDisplayName) { String strParam; Boolean bValue; strParam = prpSettings.getProperty(strProperty, strProperty); if ((strParam.equals(strProperty)) || (strParam.length() == 0)) { if (bDefaultValue != null) { printConfigMessage( strProperty, bDefaultValue.toString(), strDisplayName + " is not set in property " + strProperty + ", using default value " + bDefaultValue); } bValue = bDefaultValue; } else { bValue = GlobalConstants.isTrue(strParam) ? Boolean.TRUE : Boolean.FALSE; } if (bValue != null) { printConfigMessage(strProperty, bValue.toString(), null); } return bValue; }
/** * Retrieve boolean property value and if the value is not specified throw an exception. * * @param prpSettings - properties to retrieve the setting from * @param strProperty - name of the property to retrieve * @param strDisplayName - user friendly name of the property * @return boolean - value of the property * @throws OSSConfigException - value for the requested property is not specified */ public static Boolean getBooleanProperty( Properties prpSettings, String strProperty, String strDisplayName) throws OSSConfigException { String strParam; Boolean bValue; strParam = prpSettings.getProperty(strProperty, strProperty); if ((strParam.equals(strProperty)) || (strParam.length() == 0)) { throw new OSSConfigException(strDisplayName + " is not set in property " + strProperty); } else { bValue = GlobalConstants.isTrue(strParam) ? Boolean.TRUE : Boolean.FALSE; } printConfigMessage(strProperty, bValue.toString(), null); return bValue; }