- 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 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
Modifier and TypeMethodDescriptionlongThe 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 itsStringrepresentation.default <TYPE> TYPEReads the next line from the (standard) input (stream or file) and converts it to the given type which's instance is then returned.Creates aHeaderfrom the next line to be read.readHeader(Column<T>... aColumns) Creates aHeaderfrom the next line to be read.readHeader(Header<T> aHeader) Creates aHeaderfrom the next line to be read.Skips the next line to be read.Methods inherited from interface java.lang.AutoCloseable
closeMethods inherited from interface org.refcodes.tabular.HeaderAccessor
getHeaderMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface java.util.Iterator
forEachRemaining, hasNext, next, removeMethods 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 aHeaderfrom 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, placeholderColumninstances are inserted if needed, created by the provided (default)ColumnFactory.- Returns:
- Returns the
Headerbeing read. - Throws:
IOException- thrown in case reading from IO failed.
-
readHeader
Creates aHeaderfrom the next line to be read. The provided header is matched against the next line being read and ordered accordingly, place holderColumninstances are inserted if needed, created by the provided (default)ColumnFactory.- Parameters:
aColumns- TheColumninstances for creating the actualHeader.- Returns:
- Returns the
Headerbeing read. - Throws:
IOException- Signals that an I/O exception has occurred.
-
readHeader
Creates aHeaderfrom the next line to be read. The provided header is matched against the next line being read and ordered accordingly, place holderColumninstances are inserted if needed, created by the provided (default)ColumnFactory.- Parameters:
aHeader- TheHeaderfor creating the actualHeader.- Returns:
- Returns the
Headerbeing 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 itsStringrepresentation. -
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. TheHeaderkeys 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
Recordis being converted to.
-
toHeader
Merges the primaryHeaderwith the supplementHeader. A copy of the primaryHeaderis returned with anyColumnreplaced in the primaryHeaderwith a supplementHeader'sColumnof the same key.- Parameters:
aPrimaryHeader- the primary headeraSupplementHeader- the supplement header- Returns:
- The accordingly merged
Header.
-