001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.activemq.util;
018
019 import java.beans.PropertyEditorSupport;
020 import java.util.ArrayList;
021
022 import org.apache.activemq.command.ActiveMQDestination;
023 import org.springframework.util.StringUtils;
024
025 /**
026 * Used to serialize lists of ActiveMQDestinations.
027 * @see org.apache.activemq.util.IntrospectionSupport
028 */
029 public class ListEditor extends PropertyEditorSupport {
030
031 public static final String DEFAULT_SEPARATOR = ",";
032
033 public String getAsText() {
034 return getValue().toString();
035 }
036
037
038 public void setAsText(String text) throws IllegalArgumentException {
039 text = text.substring(1, text.length() - 1);
040 String[] array = StringUtils.delimitedListToStringArray(text, ListEditor.DEFAULT_SEPARATOR, null);
041 ArrayList<ActiveMQDestination> list = new ArrayList<ActiveMQDestination>();
042 for (String item : array) {
043 list.add(ActiveMQDestination.createDestination(item.trim(), ActiveMQDestination.QUEUE_TYPE));
044 }
045 setValue(list);
046 }
047
048 }