Package org.springframework.core.convert

Examples of org.springframework.core.convert.ConversionService


  // 从requestValue创建Attribute
  private Object createAttributeFromRequestValue(String sourceValue, String attributeName, MethodParameter parameter,
          WebDataBinderFactory binderFactory, NativeWebRequest request) throws Exception {
    DataBinder binder = binderFactory.createBinder(request, null, attributeName);
    ConversionService conversionService = binder.getConversionService();
    if (conversionService != null) {
      TypeDescriptor source = TypeDescriptor.valueOf(String.class);
      TypeDescriptor target = new TypeDescriptor(parameter);
      if (conversionService.canConvert(source, target)) {
        return binder.convertIfNecessary(sourceValue, parameter.getParameterType(), parameter);
      }
    }
    return null;
  }
View Full Code Here


  @SuppressWarnings("rawtypes")
  private Map<String, Converter> cachedConverters;

  @SuppressWarnings("rawtypes")
  public ConversionService getObject() {
    ConversionService conversionService = super.getObject();
    if (conversionService instanceof ConverterRegistry) {
      ConverterRegistry registry = (ConverterRegistry) conversionService;
      if (cachedConverters == null) {
        cachedConverters = BeanUtils.getBeansOfType(Converter.class);
        ConversionServiceFactory.registerConverters(new LinkedHashSet<Converter>(cachedConverters.values()),
View Full Code Here


  private EvaluationContext createEvaluationContext(PageContext pageContext) {
    StandardEvaluationContext context = new StandardEvaluationContext();
    context.addPropertyAccessor(new JspPropertyAccessor(pageContext));
    ConversionService conversionService = getConversionService(pageContext);
    if (conversionService != null) {
      context.setTypeConverter(new StandardTypeConverter(conversionService));
    }
    return context;
  }
View Full Code Here

    @Test
    public void shouldReturnDefaultConversionService(){
        //given
        MappingElasticsearchConverter converter = new MappingElasticsearchConverter(new SimpleElasticsearchMappingContext());
        //when
        ConversionService conversionService = converter.getConversionService();
        //then
        assertThat(conversionService, is(notNullValue()));
    }
View Full Code Here

TOP

Related Classes of org.springframework.core.convert.ConversionService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.