Examples of ConversionExecutor


Examples of org.springframework.binding.convert.ConversionExecutor

  // utility methods

  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

Examples of org.springframework.binding.convert.ConversionExecutor

  /**
   * Convert given array of String parameters to specified target type and return the resulting array.
   */
  private Object[] convert(String[] parameters, Class targetElementType) throws ConversionExecutionException {
    List list = new ArrayList(parameters.length);
    ConversionExecutor converter = conversionService.getConversionExecutor(String.class, targetElementType);
    for (int i = 0; i < parameters.length; i++) {
      list.add(converter.execute(parameters[i]));
    }
    return list.toArray((Object[]) Array.newInstance(targetElementType, parameters.length));
  }
View Full Code Here

Examples of org.springframework.binding.convert.ConversionExecutor

  protected void setUp() throws Exception {
    service = new FacesConversionService();
  }

  public void testGetAbstractType() {
    ConversionExecutor executor = service.getConversionExecutor(List.class, DataModel.class);
    ArrayList list = new ArrayList();
    list.add("foo");
    executor.execute(list);
  }
View Full Code Here

Examples of org.springframework.binding.convert.ConversionExecutor

  }

  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

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 = 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;
  }
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;
    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

Examples of org.springframework.binding.convert.ConversionExecutor

  public Object convertSourceToTargetClass(Object source, Class<?> targetClass) throws Exception {
    if (source == null) {
      return null;
    }
    Collection collection = CollectionFactory.createCollection(targetClass, DEFAULT_INITIAL_CAPACITY);
    ConversionExecutor converter = getElementConverter(source, (Class<? extends Collection<?>>) 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

      return null;
    }
    Class<?> collectionImplClass = getCollectionImplClass(targetClass);
    Constructor<?> constructor = collectionImplClass.getConstructor();
    Collection<Object> collection = (Collection<Object>) constructor.newInstance();
    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

Examples of org.springframework.binding.convert.ConversionExecutor

    Collection<?> collection = (Collection<?>) target;
    Object array = Array.newInstance(sourceClass.getComponentType(), collection.size());
    int i = 0;
    for (Object value : collection) {
      if (value != null) {
        ConversionExecutor converter;
        if (elementConverter != null) {
          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

Examples of org.springframework.binding.convert.ConversionExecutor

  public Object convertSourceToTargetClass(Object source, Class<?> targetClass) throws Exception {
    if (source == null) {
      return null;
    }
    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
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.