diff --git a/common/source/java/ch/systemsx/cisd/common/properties/PropertyUtils.java b/common/source/java/ch/systemsx/cisd/common/properties/PropertyUtils.java index 34b7d3d6b6edb63ba251dfbe24de4a0310ec4b5c..70efa9ff0113d27157f6b091cec39f173089d5c1 100644 --- a/common/source/java/ch/systemsx/cisd/common/properties/PropertyUtils.java +++ b/common/source/java/ch/systemsx/cisd/common/properties/PropertyUtils.java @@ -103,6 +103,19 @@ public final class PropertyUtils return StringUtils.isBlank(property) ? null : property.trim(); } + /** + * Searches for the property with the specified key in this property list. <code>null</code> is returned if there is no property for the specified + * key or it contains only white space characters. + * + * @return <code>null</code> or the non-trimmed value if found. + */ + public final static String getPropertyDontTrim(final Properties properties, final String propertyKey) + { + assertParameters(properties, propertyKey); + final String property = properties.getProperty(propertyKey); + return property; + } + /** * Searches for the property with the specified key in this property list. * @@ -466,21 +479,29 @@ public final class PropertyUtils final char defaultValue, final ISimpleLogger loggerOrNull) { assertParameters(properties, propertyKey); - final String charOrNull = getProperty(properties, propertyKey); + String charOrNull = getPropertyDontTrim(properties, propertyKey); if (charOrNull == null) { return defaultValue; } - if (charOrNull.length() != 1) + if (charOrNull.length() == 1) + { + return charOrNull.charAt(0); + } + charOrNull = charOrNull.trim(); + if (charOrNull.length() == 1) + { + return charOrNull.charAt(0); + } + else { if (loggerOrNull != null) { loggerOrNull.log(LogLevel.INFO, String.format(NON_CHAR_VALUE_FORMAT, charOrNull, defaultValue)); - return defaultValue; } + return defaultValue; } - return charOrNull.charAt(0); } /**