Package org.springframework.core.convert

Examples of org.springframework.core.convert.ConverterNotFoundException


    }
    else if (sourceType.isAssignableTo(targetType) && targetType.getObjectType().isInstance(source)) {
      return source;
    }
    else {
      throw new ConverterNotFoundException(sourceType, targetType);
    }   
  }
View Full Code Here


      }
    }
    Collection target = CollectionFactory.createCollection(targetType.getType(), sourceCollection.size());
    GenericConverter converter = this.conversionService.getConverter(sourceElementType, targetElementType);
    if (converter == null) {
      throw new ConverterNotFoundException(sourceElementType, targetElementType);
    }
    for (Object element : sourceCollection) {
      target.add(ConversionUtils.invokeConverter(converter, element, sourceElementType, targetElementType));
    }
    return target;
View Full Code Here

        return string.toString();
      }
      else {
        GenericConverter converter = this.conversionService.getConverter(sourceElementType, targetType);
        if (converter == null) {
          throw new ConverterNotFoundException(sourceElementType, targetType);
        }
        StringBuilder string = new StringBuilder();
        int i = 0;
        for (Object sourceElement : sourceCollection) {
          if (i > 0) {
View Full Code Here

      return source;
    }
    if (sourceType.isAssignableTo(targetType) && targetType.getObjectType().isInstance(source)) {
      return source;
    }
    throw new ConverterNotFoundException(sourceType, targetType);
  }
View Full Code Here

    if (targetType == TypeDescriptor.NULL) {
      return null;
    }
    GenericConverter converter = getConverter(sourceType, targetType);
    if (converter == null) {
      throw new ConverterNotFoundException(sourceType, targetType);
    }
    return ConversionUtils.invokeConverter(converter, source, sourceType, targetType);
  }
View Full Code Here

      if (source == null || targetType.getType().isInstance(source)) {
        logger.debug("No converter found - returning assignable source object as-is");
        return source;
      }
      else {
        throw new ConverterNotFoundException(sourceType, targetType);
      }
    }
    Object result = ConversionUtils.invokeConverter(converter, source, sourceType, targetType);
    if (logger.isDebugEnabled()) {
      logger.debug("Converted to " + StylerUtils.style(result));
View Full Code Here

        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()));
            }
        }
        //
        return value;
    }
View Full Code Here

            coffeeMachines.save(coffeeMachine);

            fail();
        } catch (MappingException me) {
            assertTrue("converter not found", me.getCause() instanceof ConverterNotFoundException);
            ConverterNotFoundException e = (ConverterNotFoundException) me.getCause();
            assertThat(asSet(DripBrew.class.getName(), EspressoBasedCoffee.class.getName()), hasItem(e.getSourceType().getName()));
            assertThat(asSet(DripBrew.class.getName(), EspressoBasedCoffee.class.getName()), hasItem(e.getTargetType().getName()));
            assertThat(e.getSourceType().getName(), is(not(equalTo(e.getTargetType().getName()))));
        }
    }
View Full Code Here

TOP

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

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.