Examples of GenericConverter


Examples of org.springframework.core.convert.converter.GenericConverter

   * no suitable converter was found
   * @see #getDefaultConverter(TypeDescriptor, TypeDescriptor)
   */
  protected GenericConverter getConverter(TypeDescriptor sourceType, TypeDescriptor targetType) {
    ConverterCacheKey key = new ConverterCacheKey(sourceType, targetType);
    GenericConverter converter = this.converterCache.get(key);
    if (converter != null) {
      return (converter != NO_MATCH ? converter : null);
    }

    converter = this.converters.find(sourceType, targetType);
View Full Code Here

Examples of org.springframework.core.convert.converter.GenericConverter

      // Search the full type hierarchy
      List<TypeDescriptor> sourceCandidates = getTypeHierarchy(sourceType);
      List<TypeDescriptor> targetCandidates = getTypeHierarchy(targetType);
      for (TypeDescriptor sourceCandidate : sourceCandidates) {
        for (TypeDescriptor targetCandidate : targetCandidates) {
          GenericConverter converter = getRegisteredConverter(
              sourceType, targetType, sourceCandidate, targetCandidate);
          if(converter != null) {
            return converter;
          }
        }
View Full Code Here

Examples of org.springframework.core.convert.converter.GenericConverter

        TypeDescriptor sourceCandidate, TypeDescriptor targetCandidate) {

      // Check specifically registered converters
      ConvertersForPair convertersForPair = converters.get(new ConvertiblePair(
        sourceCandidate.getType(), targetCandidate.getType()));
      GenericConverter converter = convertersForPair == null ? null
        : convertersForPair.getConverter(sourceType, targetType);
      if (converter != null) {
        return converter;
      }
View Full Code Here

Examples of org.springframework.core.convert.converter.GenericConverter

    TypeDescriptor targetElementType = targetType.getElementTypeDescriptor();
    if (targetElementType == TypeDescriptor.NULL || sourceType.isAssignableTo(targetElementType)) {
      target.add(source);
    }
    else {
      GenericConverter converter = this.conversionService.getConverter(sourceType, targetElementType);
      if (converter == null) {
        throw new ConverterNotFoundException(sourceType, targetElementType);
      }
      target.add(ConversionUtils.invokeConverter(converter, source, sourceType, targetElementType));
    }
View Full Code Here

Examples of org.springframework.core.convert.converter.GenericConverter

    if (sourceType.isAssignableTo(targetElementType)) {
      return fields;
    }
    else {
      Object target = Array.newInstance(targetElementType.getType(), fields.length);
      GenericConverter converter = this.conversionService.getConverter(sourceType, targetElementType);
      if (converter == null) {
        throw new ConverterNotFoundException(sourceType, targetElementType);
      }
      for (int i = 0; i < fields.length; i++) {
        Array.set(target, i, ConversionUtils.invokeConverter(converter, fields[i], sourceType, targetElementType));
View Full Code Here

Examples of org.springframework.core.convert.converter.GenericConverter

    Object target = Array.newInstance(targetElementType.getType(), 1);
    if (sourceType.isAssignableTo(targetElementType)) {
      Array.set(target, 0, source);
    }
    else {
      GenericConverter converter = this.conversionService.getConverter(sourceType, targetElementType);
      if (converter == null) {
        throw new ConverterNotFoundException(sourceType, targetElementType);
      }
      Array.set(target, 0, ConversionUtils.invokeConverter(converter, source, sourceType, targetElementType));
    }
View Full Code Here

Examples of org.springframework.core.convert.converter.GenericConverter

      for (Iterator<?> it = sourceCollection.iterator(); it.hasNext(); i++) {
        Array.set(array, i, it.next());
      }
    }
    else {
      GenericConverter converter = this.conversionService.getConverter(sourceElementType, targetElementType);
      if (converter == null) {
        throw new ConverterNotFoundException(sourceElementType, targetElementType);
      }
      for (Iterator<?> it = sourceCollection.iterator(); it.hasNext(); i++) {
        Object sourceElement = it.next();
View Full Code Here

Examples of org.springframework.core.convert.converter.GenericConverter

      for (int i = 0; i < length; i++) {
        collection.add(Array.get(source, i));
      }
    }
    else {
      GenericConverter converter = this.conversionService.getConverter(sourceElementType, targetElementType);
      if (converter == null) {
        throw new ConverterNotFoundException(sourceElementType, targetElementType);
      }
      for (int i = 0; i < length; i++) {
        Object sourceElement = Array.get(source, i);
View Full Code Here

Examples of org.springframework.core.convert.converter.GenericConverter

      for (String field : fields) {
        target.add(field);
      }
    }
    else {
      GenericConverter converter = this.conversionService.getConverter(sourceType, targetElementType);
      if (converter == null) {
        throw new ConverterNotFoundException(sourceType, targetElementType);
      }
      for (String sourceElement : fields) {
        Object targetElement = ConversionUtils.invokeConverter(
View Full Code Here

Examples of org.springframework.core.convert.converter.GenericConverter

      }
      if (sourceElementType == TypeDescriptor.NULL || sourceElementType.isAssignableTo(targetType)) {
        return firstElement;
      }
      else {
        GenericConverter converter = this.conversionService.getConverter(sourceElementType, targetType);
        if (converter == null) {
          throw new ConverterNotFoundException(sourceElementType, targetType);
        }
        return ConversionUtils.invokeConverter(converter, firstElement, sourceElementType, targetType);
      }
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.