1 16 17 package org.springframework.beans.propertyeditors; 18 19 import java.beans.PropertyEditorSupport ; 20 21 import org.springframework.util.StringUtils; 22 23 33 public class StringArrayPropertyEditor extends PropertyEditorSupport { 34 35 38 public static final String DEFAULT_SEPARATOR = ","; 39 40 private final String separator; 41 42 43 47 public StringArrayPropertyEditor() { 48 this.separator = DEFAULT_SEPARATOR; 49 } 50 51 56 public StringArrayPropertyEditor(String separator) { 57 this.separator = separator; 58 } 59 60 61 public void setAsText(String text) throws IllegalArgumentException { 62 String [] array = StringUtils.delimitedListToStringArray(text, this.separator); 63 setValue(array); 64 } 65 66 public String getAsText() { 67 String [] array = (String []) this.getValue(); 68 return StringUtils.arrayToDelimitedString(array, this.separator); 69 } 70 71 } 72 | Popular Tags |