mirror of
https://github.com/apache/activemq.git
synced 2025-02-18 16:10:45 +00:00
ACTIVEMQ-2384 remove hard dependency on spring
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@930041 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
fd65b8201a
commit
c22ea7fab0
@ -17,23 +17,44 @@
|
|||||||
package org.apache.activemq.util;
|
package org.apache.activemq.util;
|
||||||
|
|
||||||
import java.beans.PropertyEditorSupport;
|
import java.beans.PropertyEditorSupport;
|
||||||
|
import java.util.ArrayList;
|
||||||
import org.springframework.util.StringUtils;
|
import java.util.List;
|
||||||
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
|
|
||||||
public class StringArrayEditor extends PropertyEditorSupport {
|
public class StringArrayEditor extends PropertyEditorSupport {
|
||||||
|
|
||||||
public static final String DEFAULT_SEPARATOR = ",";
|
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>();
|
||||||
|
|
||||||
public String getAsText() {
|
while (stok.hasMoreTokens()) {
|
||||||
return getValue().toString();
|
list.add(stok.nextToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Object array = list.toArray(new String[list.size()]);
|
||||||
|
|
||||||
public void setAsText(String text) throws IllegalArgumentException {
|
setValue(array);
|
||||||
String[] array = StringUtils.delimitedListToStringArray(text, ListEditor.DEFAULT_SEPARATOR, null);
|
}
|
||||||
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();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user