org.springframework.batch.item.file.transform.FieldSet.getProperties()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(2.4k)|赞(0)|评价(0)|浏览(97)

本文整理了Java中org.springframework.batch.item.file.transform.FieldSet.getProperties()方法的一些代码示例,展示了FieldSet.getProperties()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FieldSet.getProperties()方法的具体详情如下:
包路径:org.springframework.batch.item.file.transform.FieldSet
类名称:FieldSet
方法名:getProperties

FieldSet.getProperties介绍

[英]Construct name-value pairs from the field names and string values. Null values are omitted.
[中]

代码示例

代码示例来源:origin: spring-projects/spring-batch

/**
 * Map the {@link FieldSet} to an object retrieved from the enclosing Spring
 * context, or to a new instance of the required type if no prototype is
 * available.
 * @throws BindException if there is a type conversion or other error (if
 * the {@link DataBinder} from {@link #createBinder(Object)} has errors
 * after binding).
 * 
 * @throws NotWritablePropertyException if the {@link FieldSet} contains a
 * field that cannot be mapped to a bean property.
 * @see org.springframework.batch.item.file.mapping.FieldSetMapper#mapFieldSet(FieldSet)
 */
@Override
public T mapFieldSet(FieldSet fs) throws BindException {
  T copy = getBean();
  DataBinder binder = createBinder(copy);
  binder.bind(new MutablePropertyValues(getBeanProperties(copy, fs.getProperties())));
  if (binder.getBindingResult().hasErrors()) {
    throw new BindException(binder.getBindingResult());
  }
  return copy;
}

代码示例来源:origin: org.springframework.xd/spring-xd-batch

@Override
public SqlParameterSource createSqlParameterSource(FieldSet item) {
  MapSqlParameterSource source = new MapSqlParameterSource();
  Properties props = item.getProperties();
  Set<String> keys = new HashSet<String>(props.stringPropertyNames());
  for (String key : keys) {
    source.addValue(key, props.get(key));
  }
  return source;
}

代码示例来源:origin: apache/servicemix-bundles

/**
 * Map the {@link FieldSet} to an object retrieved from the enclosing Spring
 * context, or to a new instance of the required type if no prototype is
 * available.
 * @throws BindException if there is a type conversion or other error (if
 * the {@link DataBinder} from {@link #createBinder(Object)} has errors
 * after binding).
 * 
 * @throws NotWritablePropertyException if the {@link FieldSet} contains a
 * field that cannot be mapped to a bean property.
 * @see org.springframework.batch.item.file.mapping.FieldSetMapper#mapFieldSet(FieldSet)
 */
@Override
public T mapFieldSet(FieldSet fs) throws BindException {
  T copy = getBean();
  DataBinder binder = createBinder(copy);
  binder.bind(new MutablePropertyValues(getBeanProperties(copy, fs.getProperties())));
  if (binder.getBindingResult().hasErrors()) {
    throw new BindException(binder.getBindingResult());
  }
  return copy;
}

相关文章