Examples of ConversionFailedException


Examples of org.springframework.core.convert.ConversionFailedException

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

Examples of org.springframework.core.convert.ConversionFailedException

    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

Examples of org.springframework.core.convert.ConversionFailedException

          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

Examples of org.springframework.core.convert.ConversionFailedException

      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

Examples of org.springframework.core.convert.ConversionFailedException

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

Examples of org.springframework.core.convert.ConversionFailedException

   * @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

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

Examples of org.springframework.core.convert.ConversionFailedException

    }
    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

Examples of org.springframework.core.convert.ConversionFailedException

          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

Examples of org.springframework.core.convert.ConversionFailedException

  public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {

    PersistentEntity<?, ?> entity = entities.getPersistentEntity(targetType.getType());

    if (entity == null) {
      throw new ConversionFailedException(sourceType, targetType, source, new IllegalArgumentException(
          "No PersistentEntity information available for " + targetType.getType()));
    }

    URI uri = (URI) source;
    String[] parts = uri.getPath().split("/");

    if (parts.length < 2) {
      throw new ConversionFailedException(sourceType, targetType, source, new IllegalArgumentException(
          "Cannot resolve URI " + uri + ". Is it local or remote? Only local URIs are resolvable."));
    }

    return domainClassConverter.convert(parts[parts.length - 1], STRING_TYPE, 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.