From c96d120faddb6cf139be93230c8e139fdc6b50a3 Mon Sep 17 00:00:00 2001 From: jakubs <jakubs> Date: Wed, 8 Apr 2015 13:59:00 +0000 Subject: [PATCH] SSDM-1730: Fix the problem when it was impossible to set tab character as a csv reader delimiter, becuase of the trim method called on a tab character. SVN: 33805 --- .../cisd/common/properties/PropertyUtils.java | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) 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 34b7d3d6b6e..70efa9ff011 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); } /** -- GitLab