IN PROGRESS - BATCH-826: Create callback for header and footer reading in xml and flat files

added header callback to FFIR
This commit is contained in:
robokaso
2008-09-11 11:44:45 +00:00
parent 13e5796b85
commit df870a5df6
3 changed files with 33 additions and 0 deletions

View File

@@ -90,10 +90,19 @@ public class FlatFileItemReader<T> extends AbstractItemReaderItemStream<T> imple
private BufferedReader reader;
private LineCallbackHandler headerCallback;
public FlatFileItemReader() {
setName(ClassUtils.getShortName(FlatFileItemReader.class));
}
/**
* headerCallback will be passed the header line before any items are read.
*/
public void setHeaderCallback(LineCallbackHandler headerCallback) {
this.headerCallback = headerCallback;
}
/**
* Setter for resource property. The location of an input stream that can be
* read.
@@ -227,6 +236,9 @@ public class FlatFileItemReader<T> extends AbstractItemReaderItemStream<T> imple
String[] names = tokenizer.tokenize(firstLine).getValues();
((AbstractLineTokenizer) tokenizer).setNames(names);
}
if (headerCallback != null) {
headerCallback.handleLine(firstLine);
}
}
}

View File

@@ -0,0 +1,12 @@
package org.springframework.batch.item.file;
/**
* Callback interface for handling a line from file. Useful e.g. for header
* processing.
*
* @author Robert Kasanicky
*/
public interface LineCallbackHandler {
void handleLine(String line);
}