Package org.jeasy.batch.core.reader
Class AbstractMultiFileRecordReader<P>
- java.lang.Object
-
- org.jeasy.batch.core.reader.AbstractMultiFileRecordReader<P>
-
- Type Parameters:
P
- type of the record's payload
- All Implemented Interfaces:
RecordReader<P>
public abstract class AbstractMultiFileRecordReader<P> extends java.lang.Object implements RecordReader<P>
Template class for multi-files record readers. Implementations should provide how to create the delegate reader increateReader()
method. Using multi-files readers assumes all files have the same format.- Author:
- Mahmoud Ben Hassine ([email protected])
-
-
Field Summary
Fields Modifier and Type Field Description protected java.nio.charset.Charset
charset
protected java.nio.file.Path
currentFile
protected AbstractFileRecordReader<P>
delegate
protected java.util.List<java.nio.file.Path>
files
protected java.util.Iterator<java.nio.file.Path>
iterator
-
Constructor Summary
Constructors Constructor Description AbstractMultiFileRecordReader(java.util.List<java.nio.file.Path> files)
Create a new multi-file record reader.AbstractMultiFileRecordReader(java.util.List<java.nio.file.Path> files, java.nio.charset.Charset charset)
Create a new multi-file record reader.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
close()
Close the reader.protected abstract AbstractFileRecordReader<P>
createReader()
void
open()
Open the reader.Record<P>
readRecord()
Read next record from the data source.
-
-
-
Field Detail
-
files
protected java.util.List<java.nio.file.Path> files
-
currentFile
protected java.nio.file.Path currentFile
-
delegate
protected AbstractFileRecordReader<P> delegate
-
iterator
protected java.util.Iterator<java.nio.file.Path> iterator
-
charset
protected java.nio.charset.Charset charset
-
-
Constructor Detail
-
AbstractMultiFileRecordReader
public AbstractMultiFileRecordReader(java.util.List<java.nio.file.Path> files)
Create a new multi-file record reader.- Parameters:
files
- to read
-
AbstractMultiFileRecordReader
public AbstractMultiFileRecordReader(java.util.List<java.nio.file.Path> files, java.nio.charset.Charset charset)
Create a new multi-file record reader.- Parameters:
files
- to readcharset
- of the file
-
-
Method Detail
-
open
public void open() throws java.lang.Exception
Description copied from interface:RecordReader
Open the reader.- Specified by:
open
in interfaceRecordReader<P>
- Throws:
java.lang.Exception
- if an error occurs during reader opening
-
readRecord
public Record<P> readRecord() throws java.lang.Exception
Description copied from interface:RecordReader
Read next record from the data source.- Specified by:
readRecord
in interfaceRecordReader<P>
- Returns:
- the next record from the data source or
null
if the end of the data source is reached - Throws:
java.lang.Exception
- if an error occurs during reading next record
-
close
public void close() throws java.lang.Exception
Description copied from interface:RecordReader
Close the reader.- Specified by:
close
in interfaceRecordReader<P>
- Throws:
java.lang.Exception
- if an error occurs during reader closing
-
createReader
protected abstract AbstractFileRecordReader<P> createReader() throws java.lang.Exception
- Throws:
java.lang.Exception
-
-