Examples of ConversionFailedException


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

    Foo foo = new Foo();
    BeanWrapperImpl wrapper = new BeanWrapperImpl(foo);
    wrapper.setConversionService(new GenericConversionService() {
      @Override
      public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
        throw new ConversionFailedException(sourceType, targetType, source, null);
      }
    });
    wrapper.setAutoGrowNestedPaths(true);
    wrapper.setPropertyValue("listOfMaps[0]['luckyNumber']", "9");
    assertEquals("9", foo.listOfMaps.get(0).get("luckyNumber"));
View Full Code Here

Examples of org.springframework.core.convert.ConversionFailedException

      if (constructor != null) {
        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/of/from(" + sourceClass.getName() +
        ") method or Constructor(" + sourceClass.getName() + ") exists on " + targetClass.getName());
  }
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

          result = this.conversionService.convert(result, resultType, targetType);
        }
        return result;
      }
      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

    }
    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

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

          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

                    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
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.