Package org.springframework.core.convert

Examples of org.springframework.core.convert.ConversionFailedException


    Object convertedValue = newValue;

    // Custom editor for this type?
    PropertyEditor editor = this.propertyEditorRegistry.findCustomEditor(requiredType, propertyName);

    ConversionFailedException firstAttemptEx = null;

    // No custom editor but custom ConversionService specified?
    ConversionService conversionService = this.propertyEditorRegistry.getConversionService();
    if (editor == null && conversionService != null && convertedValue != null && typeDescriptor != null) {
      TypeDescriptor sourceTypeDesc = TypeDescriptor.forObject(newValue);
View Full Code Here


    }
    catch (ConversionFailedException ex) {
      throw ex;
    }
    catch (Exception ex) {
      throw new ConversionFailedException(sourceType, targetType, source, ex);
    }
  }
View Full Code Here

    return result;
  }

  private void assertNotPrimitiveTargetType(TypeDescriptor sourceType, TypeDescriptor targetType) {
    if (targetType.isPrimitive()) {
      throw new ConversionFailedException(sourceType, targetType, null,
          new IllegalArgumentException("A null value cannot be assigned to a primitive type"));
    }
  }
View Full Code Here

          return constructor.newInstance(source);
        }
      }
    }
    catch (InvocationTargetException ex) {
      throw new ConversionFailedException(sourceType, targetType, source, ex.getTargetException());
    }
    catch (Throwable ex) {
      throw new ConversionFailedException(sourceType, targetType, source, ex);
    }
    throw new IllegalStateException("No static valueOf(" + sourceClass.getName() +
        ") method or Constructor(" + sourceClass.getName() + ") exists on " + targetClass.getName());
  }
View Full Code Here

      if (constructor != null) {
        try {
          target = constructor.newInstance(source);
        }
        catch (IllegalArgumentException ex) {
          throw new ConversionFailedException(sourceType, targetType, source, ex);
        }
        catch (InstantiationException ex) {
          throw new ConversionFailedException(sourceType, targetType, source, ex);
        }
        catch (IllegalAccessException ex) {
          throw new ConversionFailedException(sourceType, targetType, source, ex);
        }
        catch (InvocationTargetException ex) {
          throw new ConversionFailedException(sourceType, targetType, source, ex);
        }
      }
      else {
        throw new IllegalStateException("No static valueOf(" + sourceClass.getName() +
            ") method or Constructor(" + sourceClass.getName() + ") exists on " + targetClass.getName());
View Full Code Here

      TypeDescriptor targetType) {
    try {
      return converter.convert(source, sourceType, targetType);
    }
    catch (Exception ex) {
      throw new ConversionFailedException(sourceType, targetType, source, ex);
    }
  }
View Full Code Here

   * @param targetType the targetType to convert to
   * @return the converted null object
   */
  protected Object convertNullSource(TypeDescriptor sourceType, TypeDescriptor targetType) {
    if (targetType.isPrimitive()) {
      throw new ConversionFailedException(sourceType, targetType, null,
          new IllegalArgumentException("A null value cannot be assigned to a primitive type"));
    }
    return null;
  }
View Full Code Here

    Object convertedValue = newValue;

    // Custom editor for this type?
    PropertyEditor editor = this.propertyEditorRegistry.findCustomEditor(requiredType, propertyName);

    ConversionFailedException firstAttemptEx = null;

    // No custom editor but custom ConversionService specified?
    ConversionService conversionService = this.propertyEditorRegistry.getConversionService();
    if (editor == null && conversionService != null && convertedValue != null && typeDescriptor != null) {
      TypeDescriptor sourceTypeDesc = TypeDescriptor.forObject(newValue);
View Full Code Here

    }
    return result;
  }
  private void assertNotPrimitiveTargetType(TypeDescriptor sourceType, TypeDescriptor targetType) {
    if (targetType.isPrimitive()) {
      throw new ConversionFailedException(sourceType, targetType, null,
          new IllegalArgumentException("A null value cannot be assigned to a primitive type"));
    }   
  }
View Full Code Here

          return constructor.newInstance(source);
        }
      }
    }
    catch (InvocationTargetException ex) {
      throw new ConversionFailedException(sourceType, targetType, source, ex.getTargetException());
    }
    catch (Throwable ex) {
      throw new ConversionFailedException(sourceType, targetType, source, ex);
    }
    throw new IllegalStateException("No static valueOf(" + sourceClass.getName() +
        ") method or Constructor(" + sourceClass.getName() + ") exists on " + targetClass.getName());
  }
View Full Code Here

TOP

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

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.