/** * Converts a java.util.Map<String, String> into a String array of * (key,value,key,value,key,value...etc)<br> * If you supply values for exclusionPatterns, they will be treated as regular expressions and * each one will be matched against every key.<br> * If any of the patterns match, the key (and its value) will be left out of the resulting array. * <br> * Supplying an empty string ("") will cause everything to be excluded.<br> * If you want to include everything in the map, do not supply any exclusion patterns.<br> * * @param properties The map of strings to strings to convert * @param exclusionPatterns A list of patterns or keys to ignore * @return The resulting string array. It will have an even length. */ public static String[] getStringArray( Map<String, String> properties, String... exclusionPatterns) { Vector<String> items = new Vector<String>(); if (properties == null) { return new String[0]; } for (String key : properties.keySet()) { boolean notIncluded = false; for (String p : exclusionPatterns) { if (Regex.stringToMatcher(p, key).find()) { notIncluded = true; } } if (notIncluded == false) { items.add(key); items.add(StringFunctions.ifNull(properties.get(key))); } } return items.toArray(new String[0]); }