1 18 19 package org.objectweb.jac.aspects.gui.web; 20 21 import java.text.ParsePosition ; 22 import org.objectweb.jac.aspects.gui.FloatFormat; 23 import org.objectweb.jac.aspects.gui.Length; 24 import org.objectweb.jac.aspects.gui.NumberFormat; 25 import org.objectweb.jac.core.rtti.FieldItem; 26 27 33 public class FloatEditor extends FormatEditor 34 implements HTMLEditor 35 { 36 public FloatEditor(Object substance, FieldItem field) { 37 super(substance,field); 38 width = new Length("15ex"); 39 } 40 41 protected void initFormat(FieldItem field) { 42 format = new FloatFormat(field); 43 } 44 45 public Object parse(String s) { 46 ParsePosition pos = new ParsePosition (0); 47 Class cl = type.getActualClass(); 48 if (cl==float.class || cl==Float .class) { 49 return ((NumberFormat)format).parseFloat(s,pos); 50 } else if (cl==double.class || cl==Double .class) { 51 return ((NumberFormat)format).parseDouble(s,pos); 52 } else { 53 throw new RuntimeException ("FloatEditor: Unhandled type "+type.getName()); 54 } 55 } 56 } 57 | Popular Tags |