Package org.springframework.core.convert

Examples of org.springframework.core.convert.ConversionService.canConvert()


            value = getWidgetPrefValue(parameter, webRequest);
        }
        //
        if (value != null) {
            ConversionService conversionService = (ConversionService) webRequest.getAttribute(ConversionService.class.getName(), WebRequest.SCOPE_REQUEST);
            if (conversionService.canConvert(value.getClass(), parameter.getParameterType())) {
                value = conversionService.convert(value, parameter.getParameterType());
            } else {
                throw new ConverterNotFoundException(TypeDescriptor.forObject(value), TypeDescriptor.valueOf(parameter.getParameterType()));
            }
        }
View Full Code Here


    }

    // Use the conversion service
    ConversionService conversionService = this.dataBinder.getConversionService();
    if (conversionService != null) {
      if (conversionService.canConvert(TypeDescriptor.valueOf(String.class), typeDescriptor)) {
        return new ConvertingPropertyEditorAdapter(conversionService, typeDescriptor);
      }
    }

    // Fall back to default editors
View Full Code Here

            boolean found = true;
            int p = 0;
            Object[] args = new Object[parameterTypes.length];
            while (found && p < parameterTypes.length) {
              Class<?> parameterType = parameterTypes[p];
              boolean canConvert = conversionService.canConvert(String.class, parameterType);
              if (canConvert) {
                args[p] = conversionService.convert(data.getArguments().get(p), parameterType);
              }
              found &= canConvert;
              p++;
View Full Code Here

    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

TOP
Copyright © 2018 www.massapi.com. 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.