* The contents of this file are subject to the Mozilla Public License Version 1.1\r
* See LICENSE.TXT at the top of this package for the full license terms.\r
*/\r
+\r
package eu.etaxonomy.cdm.common;\r
\r
import java.io.BufferedReader;\r
static public String Nz(String value){\r
return (value == null ? "" : value);\r
}\r
+\r
+ \r
+ static public Integer Nz(Integer value){\r
+ return (value == null ? 0 : value);\r
+ }\r
+ \r
+ /**\r
+ * Concatenates the an Array of Strings, using the defined seperator.\r
+ * Null values are interpreted as empty Strings\r
+ * If all Strings are null a null is returned \r
+ * @param strings\r
+ * @param seperator\r
+ * @return String \r
+ */\r
+ static public String concat(CharSequence seperator, String[] strings){\r
+ String result = "";\r
+ boolean allNull = true;\r
+ for (String string : strings){\r
+ if (string != null){\r
+ if (result.length() > 0 && string.length() > 0){\r
+ result += seperator;\r
+ }\r
+ result += string;\r
+ allNull = false;\r
+ }\r
+ }\r
+ //if all strings are null result should be null, not ""\r
+ if (allNull){\r
+ return null;\r
+ }else {\r
+ return result;\r
+ }\r
+ }\r
+\r
+ static public String concat(CharSequence seperator, String string1, String string2){\r
+ String[] strings = {string1, string2};\r
+ return concat(seperator, strings);\r
+ }\r
\r
}
\ No newline at end of file