Examples of ConversionExecutor


Examples of org.springframework.binding.convert.ConversionExecutor

      return null;
    }
    Class collectionImplClass = getCollectionImplClass(targetClass);
    Constructor constructor = collectionImplClass.getConstructor(null);
    Collection collection = (Collection) constructor.newInstance(null);
    ConversionExecutor converter = getElementConverter(source, targetClass);
    int length = Array.getLength(source);
    for (int i = 0; i < length; i++) {
      Object value = Array.get(source, i);
      if (converter != null) {
        value = converter.execute(value);
      }
      collection.add(value);
    }
    return collection;
  }
View Full Code Here

Examples of org.springframework.binding.convert.ConversionExecutor

    Object array = Array.newInstance(sourceClass.getComponentType(), collection.size());
    int i = 0;
    for (Iterator it = collection.iterator(); it.hasNext(); i++) {
      Object value = it.next();
      if (value != null) {
        ConversionExecutor converter = conversionService.getConversionExecutor(value.getClass(), sourceClass
            .getComponentType());
        value = converter.execute(value);
      }
      Array.set(array, i, value);
    }
    return array;
  }
View Full Code Here

Examples of org.springframework.binding.convert.ConversionExecutor

    }
    Class sourceComponentType = source.getClass().getComponentType();
    Class targetComponentType = targetClass.getComponentType();
    int length = Array.getLength(source);
    Object targetArray = Array.newInstance(targetComponentType, length);
    ConversionExecutor converter = conversionService
        .getConversionExecutor(sourceComponentType, targetComponentType);
    for (int i = 0; i < length; i++) {
      Object value = Array.get(source, i);
      Array.set(targetArray, i, converter.execute(value));
    }
    return targetArray;
  }
View Full Code Here

Examples of org.springframework.binding.convert.ConversionExecutor

    if (source == null) {
      return null;
    }
    Class componentType = targetClass.getComponentType();
    Object array = Array.newInstance(componentType, 1);
    ConversionExecutor converter = conversionService.getConversionExecutor(source.getClass(), componentType);
    Array.set(array, 0, converter.execute(source));
    return array;
  }
View Full Code Here

Examples of org.springframework.binding.convert.ConversionExecutor

      return null;
    }
    Class collectionImplClass = getCollectionImplClass(targetClass);
    Constructor constructor = collectionImplClass.getConstructor(null);
    Collection collection = (Collection) constructor.newInstance(null);
    ConversionExecutor converter = getElementConverter(source, targetClass);
    Object value;
    if (converter != null) {
      value = converter.execute(source);
    } else {
      value = source;
    }
    collection.add(value);
    return collection;
View Full Code Here

Examples of org.springframework.binding.convert.ConversionExecutor

    public void testPropertyChangeCausesValidation() {
        DefaultFormModel fm = (DefaultFormModel) getFormModel(new TestBean());
        TestValidator v = new TestValidator();
        fm.setValidator(v);
        TestConversionService cs = new TestConversionService();
        cs.executer = new ConversionExecutor(String.class, String.class, new CopiedPublicNoOpConverter(String.class, String.class));
        fm.setConversionService(cs);
        ValueModel vm = fm.getValueModel("simpleProperty");
        // starting at 2: constructing a formmodel + creating valueModel
        int expectedCount = 2;
        assertEquals(expectedCount++, v.count);
View Full Code Here

Examples of org.springframework.binding.convert.ConversionExecutor

    }

    public void testTypeConversionThrowsExceptionRaisesValidationMessage() {
        DefaultFormModel fm = (DefaultFormModel) getFormModel(new TestBean());
        TestConversionService cs = new TestConversionService();
        cs.executer = new ConversionExecutor(String.class, Integer.class, new ExceptionConverter(String.class,
                Integer.class));
        fm.setConversionService(cs);
        final ValueModel vm = fm.getValueModel("simpleProperty", Integer.class);

        vm.setValue("test");
View Full Code Here

Examples of org.springframework.binding.convert.ConversionExecutor

    if ((sourceClass == null) || (sourceClass == targetClass)) {
      return sourceValueModel;
    }

    final ConversionService conversionService = getConversionService();
    ConversionExecutor convertTo = null;
    ConversionExecutor convertFrom = null;

    // Check for locally registered property converters
    if (propertyConversionServices.containsKey(formProperty)) {
      // TODO - extract ConfigurableConversionService interface...
      final GenericConversionService propertyConversionService = (GenericConversionService) propertyConversionServices
View Full Code Here

Examples of org.springframework.binding.convert.ConversionExecutor

    }
    assertEquals(1, cs.calls);
    assertEquals(String.class, cs.lastSource);
    assertEquals(Integer.class, cs.lastTarget);

    cs.executer = new ConversionExecutor(String.class, Integer.class, new CopiedPublicNoOpConverter(String.class,
        Integer.class));
    ValueModel cvm = fm.getValueModel("simpleProperty", Integer.class);
    assertEquals(3, cs.calls);
    assertEquals(Integer.class, cs.lastSource);
    assertEquals(String.class, cs.lastTarget);
View Full Code Here

Examples of org.springframework.binding.convert.ConversionExecutor

    ParserContext parserContext = new FluentParserContext().evaluate(model.getClass());
    Expression target = expressionParser.parseExpression(binding.getProperty(), parserContext);
    DefaultMapping mapping = new DefaultMapping(source, target);
    mapping.setRequired(binding.getRequired());
    if (binding.getConverter() != null) {
      ConversionExecutor conversionExecutor = conversionService.getConversionExecutor(binding.getConverter(),
          String.class, target.getValueType(model));
      mapping.setTypeConverter(conversionExecutor);
    }
    if (logger.isDebugEnabled()) {
      logger.debug("Adding mapping for parameter '" + binding.getProperty() + "'");
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.