activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r930041 - /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/StringArrayEditor.java
Date Thu, 01 Apr 2010 16:56:13 GMT
Author: djencks
Date: Thu Apr  1 16:56:13 2010
New Revision: 930041

URL: http://svn.apache.org/viewvc?rev=930041&view=rev
Log:
ACTIVEMQ-2384 remove hard dependency on spring

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/StringArrayEditor.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/StringArrayEditor.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/StringArrayEditor.java?rev=930041&r1=930040&r2=930041&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/StringArrayEditor.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/StringArrayEditor.java
Thu Apr  1 16:56:13 2010
@@ -17,23 +17,44 @@
 package org.apache.activemq.util;
 
 import java.beans.PropertyEditorSupport;
-
-import org.springframework.util.StringUtils;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
 
 
 public class StringArrayEditor extends PropertyEditorSupport {
 
-       public static final String DEFAULT_SEPARATOR = ",";
-
-       public String getAsText() {
-               return getValue().toString();
-       }
+    public void setAsText(String text) {
+        if (text == null || text.length() == 0) {
+            setValue(null);
+        } else {
+            StringTokenizer stok = new StringTokenizer(text, ",");
+            final List<String> list = new ArrayList<String>();
+
+            while (stok.hasMoreTokens()) {
+                list.add(stok.nextToken());
+            }
+
+            Object array = list.toArray(new String[list.size()]);
+
+            setValue(array);
+        }
+    }
+
+    public String getAsText() {
+        Object[] objects = (Object[]) getValue();
+        if (objects == null || objects.length == 0) {
+            return null;
+        }
+
+        StringBuffer result = new StringBuffer(String.valueOf(objects[0]));
+        for (int i = 1; i < objects.length; i++) {
+            result.append(",").append(objects[i]);
+        }
 
+        return result.toString();
 
-       public void setAsText(String text) throws IllegalArgumentException {
-        String[] array = StringUtils.delimitedListToStringArray(text, ListEditor.DEFAULT_SEPARATOR,
null);
-               setValue(array);
-       }
+    }
 
 }
 



Mime
View raw message