T - The type managed by the Records.Iterator<T>, HeaderAccessor<T>, InputStreamRecords<T>, Records<T>public class CsvFileRecordsImpl<T> extends CsvInputStreamRecordsImpl<T>
CsvFileRecordsImpl is an implementation of the Records
interface and provides functionality to parse CSV files. It extends the more
generic CsvInputStreamRecordsImpl for parsing CSV input streams.HeaderAccessor.HeaderBuilder<T extends HeaderAccessor.HeaderBuilder<?>>, HeaderAccessor.HeaderMutator<T>, HeaderAccessor.HeaderProperty<T>| Constructor | Description |
|---|---|
CsvFileRecordsImpl(ColumnFactory<T> aColumnFactory,
File aCsvFile) |
Constructs a
CsvFileRecordsImpl with the given parameters. |
CsvFileRecordsImpl(ColumnFactory<T> aColumnFactory,
File aCsvFile,
boolean isStrict) |
Constructs a
CsvFileRecordsImpl with the given parameters. |
CsvFileRecordsImpl(ColumnFactory<T> aColumnFactory,
File aCsvFile,
char aCsvSeparator) |
Constructs a
CsvFileRecordsImpl with the given parameters. |
CsvFileRecordsImpl(ColumnFactory<T> aColumnFactory,
File aCsvFile,
char aCsvSeparator,
boolean isStrict) |
Constructs a
CsvFileRecordsImpl with the given parameters. |
CsvFileRecordsImpl(Header<T> aHeader,
File aCsvFile) |
Constructs a
CsvFileRecordsImpl with the given parameters. |
CsvFileRecordsImpl(Header<T> aHeader,
File aCsvFile,
boolean isStrict) |
Constructs a
CsvFileRecordsImpl with the given parameters. |
CsvFileRecordsImpl(Header<T> aHeader,
File aCsvFile,
char aCsvSeparator) |
Constructs a
CsvFileRecordsImpl with the given parameters. |
CsvFileRecordsImpl(Header<T> aHeader,
File aCsvFile,
char aCsvSeparator,
boolean isStrict) |
Constructs a
CsvFileRecordsImpl with the given parameters. |
| Modifier and Type | Method | Description |
|---|---|---|
protected static String |
toFileNameFromZip(String aZipFileName) |
Truncates the ".zip" suffix from the filename and returns the result.
|
protected static InputStream |
toInputStream(File aFile) |
Returns an
InputStream from the provided File. |
getErroneousRecordCount, getHeader, hasNext, next, removeforEachRemainingpublic CsvFileRecordsImpl(Header<T> aHeader, File aCsvFile) throws FileNotFoundException, IOException, ZipException
CsvFileRecordsImpl with the given parameters.
Internally Column instances are generated according to the keys
found in the CSV top line. The Column instances are required to
convert the CSV line values. If a Header is provided, then the
Header is used for generating the Column instances
instead of the top line of the CSV file.aHeader - The Header to use when parsing the lines retrieved
from the InputStream.aCsvFile - The CSV File which to parse.FileNotFoundException - the file not found exceptionIOException - in case there were problems working with the given
File.ZipException - the zip exceptionpublic CsvFileRecordsImpl(Header<T> aHeader, File aCsvFile, char aCsvSeparator) throws FileNotFoundException, IOException, ZipException
CsvFileRecordsImpl with the given parameters.
Internally Column instances are generated according to the keys
found in the CSV top line. The Column instances are required to
convert the CSV line values. If a Header is provided, then the
Header is used for generating the Column instances
instead of the top line of the CSV file.aHeader - The Header to use when parsing the lines retrieved
from the InputStream.aCsvFile - The CSV File which to parse.aCsvSeparator - The delimiter being expected for the CSV input
stream.FileNotFoundException - the file not found exceptionIOException - in case there were problems working with the given
File.ZipException - the zip exceptionpublic CsvFileRecordsImpl(Header<T> aHeader, File aCsvFile, boolean isStrict) throws FileNotFoundException, IOException, ZipException
CsvFileRecordsImpl with the given parameters.
Internally Column instances are generated according to the keys
found in the CSV top line. The Column instances are required to
convert the CSV line values. If a Header is provided, then the
Header is used for generating the Column instances
instead of the top line of the CSV file.aHeader - The Header to use when parsing the lines retrieved
from the InputStream.aCsvFile - The CSV File which to parse.isStrict - When true, then parsing will abort with an exception in
case of parsing problems, else parsing is gracefully continued and
erroneous records are skipped. The error count
CsvInputStreamRecordsImpl.getErroneousRecordCount() is incremented by each
erroneous Record.FileNotFoundException - the file not found exceptionIOException - in case there were problems working with the given
File.ZipException - the zip exceptionpublic CsvFileRecordsImpl(Header<T> aHeader, File aCsvFile, char aCsvSeparator, boolean isStrict) throws FileNotFoundException, IOException, ZipException
CsvFileRecordsImpl with the given parameters.
Internally Column instances are generated according to the keys
found in the CSV top line. The Column instances are required to
convert the CSV line values. If a Header is provided, then the
Header is used for generating the Column instances
instead of the top line of the CSV file.aHeader - The Header to use when parsing the lines retrieved
from the InputStream.aCsvFile - The CSV File which to parse.aCsvSeparator - The delimiter being expected for the CSV input
stream.isStrict - When true, then parsing will abort with an exception in
case of parsing problems, else parsing is gracefully continued and
erroneous records are skipped. The error count
CsvInputStreamRecordsImpl.getErroneousRecordCount() is incremented by each
erroneous Record.FileNotFoundException - the file not found exceptionIOException - in case there were problems working with the given
File.ZipException - the zip exceptionpublic CsvFileRecordsImpl(ColumnFactory<T> aColumnFactory, File aCsvFile) throws FileNotFoundException, IOException, ZipException
CsvFileRecordsImpl with the given parameters. This
constructor supports a ColumnFactory for creating Column
instance according to the keys found in the CSV top line. The
Column instances are required to convert the CSV line values from
the storage format to the actual required type.aColumnFactory - A ColumnFactory to be used to generate
Column instances from the top line of the CSF file,
required for parsing the CSV lines and converting them to
Record instances.aCsvFile - The CSV File which to parse.FileNotFoundException - the file not found exceptionIOException - in case there were problems working with the given
File.ZipException - the zip exceptionpublic CsvFileRecordsImpl(ColumnFactory<T> aColumnFactory, File aCsvFile, char aCsvSeparator) throws FileNotFoundException, IOException, ZipException
CsvFileRecordsImpl with the given parameters. This
constructor supports a ColumnFactory for creating Column
instance according to the keys found in the CSV top line. The
Column instances are required to convert the CSV line values from
the storage format to the actual required type.aColumnFactory - A ColumnFactory to be used to generate
Column instances from the top line of the CSF file,
required for parsing the CSV lines and converting them to
Record instances.aCsvFile - The CSV File which to parse.aCsvSeparator - The delimiter being expected for the CSV input
stream.FileNotFoundException - the file not found exceptionIOException - in case there were problems working with the given
File.ZipException - the zip exceptionpublic CsvFileRecordsImpl(ColumnFactory<T> aColumnFactory, File aCsvFile, boolean isStrict) throws FileNotFoundException, IOException, ZipException
CsvFileRecordsImpl with the given parameters. This
constructor supports a ColumnFactory for creating Column
instance according to the keys found in the CSV top line. The
Column instances are required to convert the CSV line values from
the storage format to the actual required type.aColumnFactory - A ColumnFactory to be used to generate
Column instances from the top line of the CSF file,
required for parsing the CSV lines and converting them to
Record instances.aCsvFile - The CSV File which to parse.isStrict - When true, then parsing will abort with an exception in
case of parsing problems, else parsing is gracefully continued and
erroneous records are skipped. The error count
CsvInputStreamRecordsImpl.getErroneousRecordCount() is incremented by each
erroneous Record.FileNotFoundException - the file not found exceptionIOException - in case there were problems working with the given
File.ZipException - the zip exceptionpublic CsvFileRecordsImpl(ColumnFactory<T> aColumnFactory, File aCsvFile, char aCsvSeparator, boolean isStrict) throws FileNotFoundException, IOException, ZipException
CsvFileRecordsImpl with the given parameters. This
constructor supports a ColumnFactory for creating Column
instance according to the keys found in the CSV top line. The
Column instances are required to convert the CSV line values from
the storage format to the actual required type.aColumnFactory - A ColumnFactory to be used to generate
Column instances from the top line of the CSF file,
required for parsing the CSV lines and converting them to
Record instances.aCsvFile - The CSV File which to parse.aCsvSeparator - The delimiter being expected for the CSV input
stream.isStrict - When true, then parsing will abort with an exception in
case of parsing problems, else parsing is gracefully continued and
erroneous records are skipped. The error count
CsvInputStreamRecordsImpl.getErroneousRecordCount() is incremented by each
erroneous Record.FileNotFoundException - the file not found exceptionIOException - in case there were problems working with the given
File.ZipException - the zip exceptionprotected static InputStream toInputStream(File aFile) throws ZipException, IOException, FileNotFoundException
InputStream from the provided File. In case
the file points to a ZIP compressed file, then the uncompressed data is
provided by the InputStream.aFile - The File for which to get the InputStream.InputStream, in case of a ZIP compressed File,
an uncompressed InputStream is returned.ZipException - in case there were problems when accessing the ZIP
compressed File.IOException - in case there were problems working with the
File.FileNotFoundException - in case there was none such File
found.protected static String toFileNameFromZip(String aZipFileName)
aZipFileName - The file name of the ZIP file for which to get the
"inner" file name.Copyright © 2018. All rights reserved.