-
- 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 theRecords
with functionality for file based implementations regarding header management and means to monitor the state of reading data. ReadingRecord
instances may cause 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
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description long
getErroneousRecordCount()
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
nextType(Class<TYPE> aClass)
Reads the next line from the (standard) input (stream or file) and converts it to the given type which's instance is then returned.Header<T>
readHeader()
Creates aHeader
from the next line to be read.Header<T>
readHeader(Column<T>... aColumns)
Creates aHeader
from the next line to be read.Header<T>
readHeader(Header<T> aHeader)
Creates aHeader
from the next line to be read.String
skipHeader()
Skips the next line to be read.default Header<T>
toHeader(Header<T> aPrimaryHeader, Header<T> aSupplementHeader)
-
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
-
-
-
-
Method Detail
-
getErroneousRecordCount
long getErroneousRecordCount()
The number of erroneous records which were not read by theRecordReader
.- Returns:
- the erroneous record count
-
readHeader
Header<T> readHeader() throws IOException
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
Header<T> readHeader(Column<T>... aColumns) throws IOException
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
Header<T> readHeader(Header<T> aHeader) throws IOException
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
String skipHeader() throws IOException
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
default <TYPE> TYPE nextType(Class<TYPE> aClass)
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
default Header<T> toHeader(Header<T> aPrimaryHeader, Header<T> aSupplementHeader)
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
.
-
-