1 16 package org.springframework.binding.format.support; 17 18 import java.beans.PropertyEditorSupport ; 19 20 import org.springframework.binding.format.Formatter; 21 22 26 public class FormatterPropertyEditor extends PropertyEditorSupport { 27 28 31 private Formatter formatter; 32 33 36 private Class targetClass; 37 38 42 public FormatterPropertyEditor(Formatter formatter) { 43 this.formatter = formatter; 44 } 45 46 52 public FormatterPropertyEditor(Formatter formatter, Class targetClass) { 53 this.formatter = formatter; 54 this.targetClass = targetClass; 55 } 56 57 public String getAsText() { 58 return formatter.formatValue(getValue()); 59 } 60 61 public void setAsText(String text) throws IllegalArgumentException { 62 setValue(formatter.parseValue(text, targetClass)); 63 } 64 } | Popular Tags |