1 /* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 package org.springframework.security;
17
18 import org.springframework.util.StringUtils;
19
20 import java.beans.PropertyEditorSupport;
21
22 /**
23 * A property editor that can create a populated {@link ConfigAttributeDefinition} from a comma separated list of
24 * values.
25 * <p>
26 * Trims preceding and trailing spaces from presented command separated tokens, as this can be a source
27 * of hard-to-spot configuration issues for end users.
28 *
29 * @author Ben Alex
30 * @version $Id: ConfigAttributeEditor.java 2748 2008-03-17 14:10:22Z luke_t $
31 */
32 public class ConfigAttributeEditor extends PropertyEditorSupport {
33 //~ Methods ========================================================================================================
34
35 public void setAsText(String s) throws IllegalArgumentException {
36 if (StringUtils.hasText(s)) {
37 setValue(new ConfigAttributeDefinition(StringUtils.commaDelimitedListToStringArray(s)));
38 } else {
39 setValue(null);
40 }
41 }
42 }