From 9effe1630d97039b3e01cd9b58ed07e75be1d63c Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Mon, 25 Feb 2013 08:40:30 -0500
Subject: [PATCH] Merge pull request #75 from thefake/master

---
 src/com/gitblit/utils/ArrayUtils.java |   38 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/src/com/gitblit/utils/ArrayUtils.java b/src/com/gitblit/utils/ArrayUtils.java
index 635d27a..6583467 100644
--- a/src/com/gitblit/utils/ArrayUtils.java
+++ b/src/com/gitblit/utils/ArrayUtils.java
@@ -15,7 +15,9 @@
  */
 package com.gitblit.utils;
 
+import java.util.ArrayList;
 import java.util.Collection;
+import java.util.List;
 
 
 /**
@@ -26,6 +28,14 @@
  */
 public class ArrayUtils {
 
+	public static boolean isEmpty(byte [] array) {
+		return array == null || array.length == 0;
+	}
+
+	public static boolean isEmpty(char [] array) {
+		return array == null || array.length == 0;
+	}
+
 	public static boolean isEmpty(Object [] array) {
 		return array == null || array.length == 0;
 	}
@@ -33,4 +43,32 @@
 	public static boolean isEmpty(Collection<?> collection) {
 		return collection == null || collection.size() == 0;
 	}
+	
+	public static String toString(Collection<?> collection) {
+		if (isEmpty(collection)) {
+			return "";
+		}
+		StringBuilder sb = new StringBuilder();
+		for (Object o : collection) {
+			sb.append(o.toString()).append(", ");
+		}
+		// trim trailing comma-space
+		sb.setLength(sb.length() - 2);
+		return sb.toString();
+	}
+	
+	public static Collection<String> fromString(String value) {
+		if (StringUtils.isEmpty(value)) {
+			value = "";
+		}
+		List<String> list = new ArrayList<String>();
+		String [] values = value.split(",|;");
+		for (String v : values) {
+			String string = v.trim();
+			if (!StringUtils.isEmpty(string)) {
+				list.add(string);
+			}
+		}
+		return list;
+	}
 }

--
Gitblit v1.9.1