1 22 package org.jboss.test.jmx.xmbean; 23 24 import java.beans.PropertyEditorSupport ; 25 26 30 public class CustomTypeEditor extends PropertyEditorSupport 31 { 32 37 public void setAsText(String text) throws IllegalArgumentException 38 { 39 int dot = text.indexOf('.'); 40 if( dot < 0 ) 41 throw new IllegalArgumentException ("CustomType text must be 'x.y'"); 42 int x = Integer.parseInt(text.substring(0, dot)); 43 int y = Integer.parseInt(text.substring(dot+1)); 44 setValue(new CustomType(x, y)); 45 } 46 47 public String getAsText() 48 { 49 CustomType type = (CustomType) getValue(); 50 return type.getX() + "." + type.getY(); 51 } 52 } 53 | Popular Tags |