Commit 4ed9198f authored by Matt Tucker's avatar Matt Tucker Committed by matt

Added methods to convert between Strings and Collections.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@3939 b35dd754-fafc-0310-a699-88a17e54d16e
parent bd3ec7c0
......@@ -892,4 +892,36 @@ public class StringUtils {
public static String dateToMillis(Date date) {
return zeroPadString(Long.toString(date.getTime()), 15);
}
/**
* Returns a collection of Strings as a comma-delimitted list of strings.
*
* @return a String representing the Collection.
*/
public static String collectionToString(Collection<String> list) {
StringBuilder buf = new StringBuilder();
String delim = "";
for (String element : list) {
buf.append(delim);
buf.append(element);
delim = ",";
}
return buf.toString();
}
/**
* Returns a comma-delimitted list of Strings as a Collection.
*
* @return a Collection representing the String.
*/
public static Collection<String> stringToCollection(String string) {
Collection<String> collection = new ArrayList<String>();
if (string != null) {
StringTokenizer tokens = new StringTokenizer(string, ",");
while (tokens.hasMoreTokens()) {
collection.add((String)tokens.nextToken());
}
}
return collection;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment