RESOLVED - BATCH-872: RFC: Should FileWriterCallback have two methods, one for headers and one for footers?

applied patch
This commit is contained in:
robokaso
2008-11-25 09:38:24 +00:00
parent 477df02abe
commit 9474d25b09
6 changed files with 49 additions and 28 deletions

View File

@@ -3,10 +3,10 @@ package org.springframework.batch.sample.support;
import java.io.IOException;
import java.io.Writer;
import org.springframework.batch.item.file.FileWriterCallback;
import org.springframework.batch.item.file.FlatFileHeaderCallback;
import org.springframework.batch.item.file.FlatFileItemReader;
import org.springframework.batch.item.file.FlatFileItemWriter;
import org.springframework.batch.item.file.LineCallbackHandler;
import org.springframework.batch.item.file.FlatFileItemReader;
import org.springframework.util.Assert;
/**
@@ -14,7 +14,7 @@ import org.springframework.util.Assert;
* {@link FlatFileItemWriter} and copy header line from input file to output
* file.
*/
public class HeaderCopyCallback implements LineCallbackHandler, FileWriterCallback {
public class HeaderCopyCallback implements LineCallbackHandler, FlatFileHeaderCallback {
private String header = "";
@@ -23,7 +23,7 @@ public class HeaderCopyCallback implements LineCallbackHandler, FileWriterCallba
this.header = line;
}
public void write(Writer writer) throws IOException {
public void writeHeader(Writer writer) throws IOException {
writer.write("header from input: " + header);
}

View File

@@ -5,16 +5,16 @@ import java.io.Writer;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.listener.StepExecutionListenerSupport;
import org.springframework.batch.item.file.FileWriterCallback;
import org.springframework.batch.item.file.FlatFileFooterCallback;
/**
* Writes summary info in the footer of a file.
*/
public class SummaryFooterCallback extends StepExecutionListenerSupport implements FileWriterCallback{
public class SummaryFooterCallback extends StepExecutionListenerSupport implements FlatFileFooterCallback{
private StepExecution stepExecution;
public void write(Writer writer) throws IOException {
public void writeFooter(Writer writer) throws IOException {
writer.write("footer - number of items written: " + stepExecution.getWriteCount());
}