OPEN - issue BATCH-371: FlatFileItemWriter no longer uses LineAggregator

http://jira.springframework.org/browse/BATCH-371

Changed the interface of LineAggregator for symmetry with LineTokenizer.
This commit is contained in:
dsyer
2008-02-20 08:55:35 +00:00
parent 2d9a4fb570
commit f6bd90fc3e
12 changed files with 116 additions and 89 deletions

View File

@@ -16,6 +16,7 @@
package org.springframework.batch.sample;
import org.springframework.batch.io.file.mapping.FieldSet;
import org.springframework.batch.io.file.transform.LineAggregator;
@@ -24,16 +25,16 @@ import org.springframework.batch.io.file.transform.LineAggregator;
*
* @author robert.kasanicky
*/
public class LineAggregatorStub implements LineAggregator {
public class StubLineAggregator implements LineAggregator {
/**
* Concatenates arguments. Ignores the LineDescriptor.
*/
public String aggregate(String[] args) {
public String aggregate(FieldSet fieldSet) {
String result = "";
for (int i = 1; i < args.length; i++) {
result = result + args[i];
for (int i = 1; i < fieldSet.getFieldCount(); i++) {
result = result + fieldSet.readString(i);
}
return result;

View File

@@ -12,7 +12,7 @@ import junit.framework.TestCase;
import org.springframework.batch.io.file.transform.LineAggregator;
import org.springframework.batch.item.ItemWriter;
import org.springframework.batch.item.writer.AbstractItemWriter;
import org.springframework.batch.sample.LineAggregatorStub;
import org.springframework.batch.sample.StubLineAggregator;
import org.springframework.batch.sample.domain.Address;
import org.springframework.batch.sample.domain.BillingInfo;
import org.springframework.batch.sample.domain.Customer;
@@ -56,7 +56,7 @@ public class FlatFileOrderWriterTests extends TestCase {
order.setTotalPrice(BigDecimal.valueOf(0));
//create aggregator stub
LineAggregator aggregator = new LineAggregatorStub();
LineAggregator aggregator = new StubLineAggregator();
//create map of aggregators and set it to writer
Map aggregators = new HashMap();