1 17 package org.apache.geronimo.common.propertyeditor; 18 19 import java.beans.PropertyEditorSupport ; 20 import java.util.Collection ; 21 import java.util.StringTokenizer ; 22 23 29 public abstract class AbstractCollectionEditor extends PropertyEditorSupport { 30 31 36 protected abstract Collection createCollection(); 37 38 public void setAsText(String text) { 39 if (text == null) { 40 setValue(null); 41 } else { 42 if (text.startsWith("[")) { 43 text = text.substring(1); 44 } 45 if (text.endsWith("]")) { 46 text = text.substring(0, text.length() - 1); 47 } 48 Collection collection = createCollection(); 49 StringTokenizer stok = new StringTokenizer (text, ","); 50 51 while (stok.hasMoreTokens()) { 52 collection.add(stok.nextToken().trim()); 53 } 54 55 setValue(collection); 56 } 57 } 58 } 59 | Popular Tags |