- Type Parameters:
T
- The type managed by theRecords
.
- All Superinterfaces:
AutoCloseable
,HeaderAccessor<T>
,Iterable<Record<T>>
,Iterator<Record<T>>
,Records<T>
,org.refcodes.io.RowReader<String[]>
- All Known Implementing Classes:
CsvRecordReader
,CsvStringRecordReader
public interface RecordReader<T>
extends AutoCloseable, Records<T>, HeaderAccessor<T>, org.refcodes.io.RowReader<String[]>
Extends the
Records
with functionality for file based implementations
regarding header management and means to monitor the state of reading data.
Reading Record
instances may aCause problems but no abortion of an
operation (if desired), the statistics of the problems may be reported by an
implementation of this interface.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.refcodes.tabular.HeaderAccessor
HeaderAccessor.HeaderBuilder<T extends HeaderAccessor.HeaderBuilder<?>>, HeaderAccessor.HeaderMutator<T>, HeaderAccessor.HeaderProperty<T>
-
Method Summary
Modifier and TypeMethodDescriptionlong
The number of erroneous records which were not read by theRecordReader
.String[]
nextRow()
Reads the next line from the (standard) input (stream or file) and returns an array of itsString
representation.default <TYPE> TYPE
Reads the next line from the (standard) input (stream or file) and converts it to the given type which's instance is then returned.Creates aHeader
from the next line to be read.readHeader
(Column<T>... aColumns) Creates aHeader
from the next line to be read.readHeader
(Header<T> aHeader) Creates aHeader
from the next line to be read.Skips the next line to be read.Methods inherited from interface java.lang.AutoCloseable
close
Methods inherited from interface org.refcodes.tabular.HeaderAccessor
getHeader
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface java.util.Iterator
forEachRemaining, hasNext, next, remove
Methods inherited from interface org.refcodes.io.RowReader
hasNext, nextRaw
-
Method Details
-
getErroneousRecordCount
long getErroneousRecordCount()The number of erroneous records which were not read by theRecordReader
.- Returns:
- the erroneous record count
-
readHeader
Creates aHeader
from the next line to be read. In case a header has already been provided (in the constructor), then the according header is matched against the next line being read and ordered accordingly, placeholderColumn
instances are inserted if needed, created by the provided (default)ColumnFactory
.- Returns:
- Returns the
Header
being read. - Throws:
IOException
- thrown in case reading from IO failed.
-
readHeader
Creates aHeader
from the next line to be read. The provided header is matched against the next line being read and ordered accordingly, place holderColumn
instances are inserted if needed, created by the provided (default)ColumnFactory
.- Parameters:
aColumns
- TheColumn
instances for creating the actualHeader
.- Returns:
- Returns the
Header
being read. - Throws:
IOException
- Signals that an I/O exception has occurred.
-
readHeader
Creates aHeader
from the next line to be read. The provided header is matched against the next line being read and ordered accordingly, place holderColumn
instances are inserted if needed, created by the provided (default)ColumnFactory
.- Parameters:
aHeader
- TheHeader
for creating the actualHeader
.- Returns:
- Returns the
Header
being read. - Throws:
IOException
- Signals that an I/O exception has occurred.
-
skipHeader
Skips the next line to be read. This line will not be processed by theIterator.next()
method. This methods is useful when skipping the first line (header).- Returns:
- The line being skipped.
- Throws:
IOException
- thrown in case if IO problems.
-
nextRow
String[] nextRow()Reads the next line from the (standard) input (stream or file) and returns an array of itsString
representation. -
nextType
Reads the next line from the (standard) input (stream or file) and converts it to the given type which's instance is then returned. TheHeader
keys must match the type's properties.- Type Parameters:
TYPE
- The type of the element to which the line to be read is to be converted to.- Parameters:
aClass
- the type of the instance to be created.- Returns:
- The instance of the type to which the
Record
is being converted to.
-
toHeader
Merges the primaryHeader
with the supplementHeader
. A copy of the primaryHeader
is returned with anyColumn
replaced in the primaryHeader
with a supplementHeader
'sColumn
of the same key.- Parameters:
aPrimaryHeader
- the primary headeraSupplementHeader
- the supplement header- Returns:
- The accordingly merged
Header
.
-