1 16 package org.springframework.binding.convert.support; 17 18 import java.beans.PropertyEditorSupport ; 19 20 import org.springframework.binding.convert.ConversionExecutor; 21 import org.springframework.util.Assert; 22 23 31 public class ConverterPropertyEditorAdapter extends PropertyEditorSupport { 32 33 private ConversionExecutor conversionExecutor; 34 35 public ConverterPropertyEditorAdapter(ConversionExecutor conversionExecutor) { 36 Assert.notNull(conversionExecutor, "A conversion executor is required"); 37 Assert.isTrue(conversionExecutor.getSourceClass().equals(String .class), 38 "A string conversion executor is required"); 39 this.conversionExecutor = conversionExecutor; 40 } 41 42 public Class getTargetClass() { 43 return conversionExecutor.getTargetClass(); 44 } 45 46 public void setAsText(String text) throws IllegalArgumentException { 47 setValue(conversionExecutor.execute(text)); 48 } 49 50 public String getAsText() { 51 throw new UnsupportedOperationException (); 52 } 53 } | Popular Tags |