Package org.springframework.binding.convert

Examples of org.springframework.binding.convert.ConversionExecutor.execute()


    int length = Array.getLength(source);
    Object targetArray = Array.newInstance(targetComponentType, length);
    ConversionExecutor converter = getElementConverter(sourceComponentType, targetComponentType);
    for (int i = 0; i < length; i++) {
      Object value = Array.get(source, i);
      Array.set(targetArray, i, converter.execute(value));
    }
    return targetArray;
  }

  private ConversionExecutor getElementConverter(Class<?> sourceComponentType, Class<?> targetComponentType) {
View Full Code Here


    if (elementConverter != null) {
      converter = elementConverter;
    } else {
      converter = conversionService.getConversionExecutor(source.getClass(), componentType);
    }
    Array.set(array, 0, converter.execute(source));
    return array;
  }
}
View Full Code Here

    ConversionExecutor converter = getArrayElementConverter(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

          converter = elementConverter;
        } else {
          converter = conversionService.getConversionExecutor(value.getClass(),
              sourceClass.getComponentType());
        }
        value = converter.execute(value);
      }
      Array.set(array, i++, value);
    }
    return array;
  }
View Full Code Here

    Collection targetCollection = CollectionFactory.createCollection(targetClass, DEFAULT_INITIAL_SIZE);
    ConversionExecutor elementConverter = getElementConverter(source, (Class<? extends Collection<?>>) targetClass);
    Collection sourceCollection = (Collection) source;
    for (Object value : sourceCollection) {
      if (elementConverter != null) {
        value = elementConverter.execute(value);
      }
      targetCollection.add(value);
    }
    return targetCollection;
  }
View Full Code Here

  public void testGetAbstractType() {
    ConversionExecutor executor = this.service.getConversionExecutor(List.class, DataModel.class);
    ArrayList<Object> list = new ArrayList<Object>();
    list.add("foo");
    executor.execute(list);
  }

}
View Full Code Here

  }

  public Object executeConversion(Object source, Class<?> targetClass) throws ConversionException {
    if (source != null) {
      ConversionExecutor conversionExecutor = getConversionExecutor(source.getClass(), targetClass);
      return conversionExecutor.execute(source);
    } else {
      return null;
    }
  }
View Full Code Here

  }

  public Object executeConversion(String converterId, Object source, Class<?> targetClass) throws ConversionException {
    if (source != null) {
      ConversionExecutor conversionExecutor = getConversionExecutor(converterId, source.getClass(), targetClass);
      return conversionExecutor.execute(source);
    } else {
      return null;
    }
  }
View Full Code Here

  private Object getConvertedValue(FlowElementAttribute attribute) {
    if (attribute.needsTypeConversion()) {
      Class<?> targetType = fromStringToClass(attribute.getType());
      ConversionExecutor converter = flowBuilderServices.getConversionService().getConversionExecutor(
          String.class, targetType);
      return converter.execute(attribute.getValue());
    } else {
      return attribute.getValue();
    }
  }
View Full Code Here

  private Object getConvertedValue(FlowElementAttribute attribute) {
    if (attribute.needsTypeConversion()) {
      Class<?> targetType = fromStringToClass(attribute.getType());
      ConversionExecutor converter = conversionService.getConversionExecutor(String.class, targetType);
      return converter.execute(attribute.getValue());
    } else {
      return attribute.getValue();
    }
  }
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.