diff --git a/common/source/java/ch/systemsx/cisd/common/utilities/PropertyUtils.java b/common/source/java/ch/systemsx/cisd/common/utilities/PropertyUtils.java index fef27ebbd7a027302f15023d04a1a873bded5abd..d160ccb26385f32fc8a75b0333388ae183585cd2 100644 --- a/common/source/java/ch/systemsx/cisd/common/utilities/PropertyUtils.java +++ b/common/source/java/ch/systemsx/cisd/common/utilities/PropertyUtils.java @@ -83,7 +83,31 @@ public final class PropertyUtils } return property; } - + + /** + * Returns a certain property from the specified properties. + * + * @return the property value without leading and trailing white spaces. + * @throws ConfigurationFailureException if no property found or the result would be an empty + * string. + */ + public static String getProperty(Properties properties, String propertyKey) + throws ConfigurationFailureException + { + assertParameters(properties, propertyKey); + String property = properties.getProperty(propertyKey); + if (property == null) + { + throw new ConfigurationFailureException("Unspecified property '" + propertyKey + "'."); + } + property = property.trim(); + if (property.length() == 0) + { + throw new ConfigurationFailureException("Property '" + propertyKey + + "' is an empty string."); + } + return property; + } /** * Looks up given <var>propertyKey</var> in given <var>properties</var>. *