Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  * Copyright 2006-2007 the original author or authors.
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * See the License for the specific language governing permissions and
 * limitations under the License.
package org.springframework.batch.item.file.transform;
An abstract LineAggregator implementation that utilizes a FieldExtractor to convert the incoming object to an array of its parts. Extending classes must decide how those parts will be aggregated together.

Dan Garrette
public abstract class ExtractorLineAggregator<T> implements LineAggregator<T> {
Public setter for the field extractor responsible for splitting an input object up into an array of objects. Defaults to PassThroughFieldExtractor.

fieldExtractor The field extractor to set
	public void setFieldExtractor(FieldExtractor<T> fieldExtractor) {
		this. = fieldExtractor;

Extract fields from the given item using the FieldExtractor and then aggregate them. Any null field returned by the extractor will be replaced by an empty String. Null items are not allowed.

	public String aggregate(T item) {
		Object[] fields = this..extract(item);
		// Replace nulls with empty strings
		Object[] args = new Object[fields.length];
		for (int i = 0; i < fields.lengthi++) {
			if (fields[i] == null) {
				args[i] = "";
			else {
				args[i] = fields[i];
		return this.doAggregate(args);

Aggregate provided fields into single String.

fields An array of the fields that must be aggregated
aggregated string
	protected abstract String doAggregate(Object[] fields);
New to GrepCode? Check out our FAQ X