1 16 package org.springframework.binding.format.support; 17 18 import java.beans.PropertyEditor ; 19 20 import org.springframework.util.Assert; 21 22 26 public class PropertyEditorFormatter extends AbstractFormatter { 27 28 private PropertyEditor propertyEditor; 29 30 public PropertyEditorFormatter(PropertyEditor propertyEditor) { 31 super(); 32 Assert.notNull(propertyEditor, "Property editor is required"); 33 this.propertyEditor = propertyEditor; 34 } 35 36 public PropertyEditor getPropertyEditor() { 37 return propertyEditor; 38 } 39 40 protected String doFormatValue(Object value) { 41 propertyEditor.setValue(value); 42 return propertyEditor.getAsText(); 43 } 44 45 protected Object doParseValue(String formattedValue, Class targetClass) { 46 propertyEditor.setAsText(formattedValue); 47 return propertyEditor.getValue(); 48 } 49 } | Popular Tags |