1 22 package org.jboss.util.propertyeditor; 23 24 import java.beans.PropertyEditorSupport ; 25 import java.util.StringTokenizer ; 26 27 32 public class IntArrayEditor extends PropertyEditorSupport 33 { 34 37 public void setAsText(final String text) 38 { 39 StringTokenizer stok = new StringTokenizer (text, ",\r\n"); 40 int[] theValue = new int[stok.countTokens()]; 41 int i = 0; 42 while (stok.hasMoreTokens()) 43 { 44 theValue[i++] = Integer.decode(stok.nextToken()).intValue(); 45 } 46 setValue(theValue); 47 } 48 49 52 public String getAsText() 53 { 54 int[] theValue = (int[]) getValue(); 55 StringBuffer text = new StringBuffer (); 56 int length = theValue == null ? 0 : theValue.length; 57 for(int n = 0; n < length; n ++) 58 { 59 if (n > 0) 60 text.append(','); 61 text.append(theValue[n]); 62 } 63 return text.toString(); 64 } 65 } 66 | Popular Tags |