Search in sources :

Example 6 with StringValueResolver

use of org.springframework.util.StringValueResolver in project spring-framework by spring-projects.

the class NumberFormattingTests method setUp.

@Before
public void setUp() {
    DefaultConversionService.addDefaultConverters(conversionService);
    conversionService.setEmbeddedValueResolver(new StringValueResolver() {

        @Override
        public String resolveStringValue(String strVal) {
            if ("${pattern}".equals(strVal)) {
                return "#,##.00";
            } else {
                return strVal;
            }
        }
    });
    conversionService.addFormatterForFieldType(Number.class, new NumberStyleFormatter());
    conversionService.addFormatterForFieldAnnotation(new NumberFormatAnnotationFormatterFactory());
    LocaleContextHolder.setLocale(Locale.US);
    binder = new DataBinder(new TestBean());
    binder.setConversionService(conversionService);
}
Also used : StringValueResolver(org.springframework.util.StringValueResolver) DataBinder(org.springframework.validation.DataBinder) Before(org.junit.Before)

Aggregations

StringValueResolver (org.springframework.util.StringValueResolver)6 Before (org.junit.Before)1 Test (org.junit.Test)1 BeanDefinitionStoreException (org.springframework.beans.factory.BeanDefinitionStoreException)1 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)1 BeanDefinitionVisitor (org.springframework.beans.factory.config.BeanDefinitionVisitor)1 DefaultListableBeanFactory (org.springframework.beans.factory.support.DefaultListableBeanFactory)1 ConversionService (org.springframework.core.convert.ConversionService)1 DataBinder (org.springframework.validation.DataBinder)1