Package org.refcodes.tabular
Class CsvRecordsReader<T>
- java.lang.Object
-
- org.refcodes.tabular.CsvRecordsReader<T>
-
- Type Parameters:
T
- The type managed by theRecords
.
- All Implemented Interfaces:
java.lang.AutoCloseable
,java.lang.Iterable<T>
,java.util.Iterator<T>
,org.refcodes.mixin.DelimiterAccessor
,org.refcodes.mixin.DelimiterAccessor.DelimiterBuilder<T>
,org.refcodes.mixin.DelimiterAccessor.DelimiterMutator
,org.refcodes.mixin.DelimiterAccessor.DelimiterProperty
,org.refcodes.mixin.TrimAccessor
,org.refcodes.mixin.TrimAccessor.TrimBuilder<T>
,org.refcodes.mixin.TrimAccessor.TrimMutator
,org.refcodes.mixin.TrimAccessor.TrimProperty
,HeaderAccessor<T>
,Records<T>
,RecordsReader<T>
,org.refcodes.textual.CsvEscapeModeAccessor
,org.refcodes.textual.CsvEscapeModeAccessor.CsvEscapeModeBuilder<T>
,org.refcodes.textual.CsvEscapeModeAccessor.CsvEscapeModeMutator
,org.refcodes.textual.CsvEscapeModeAccessor.CsvEscapeModeProperty
,org.refcodes.textual.CsvMixin
- Direct Known Subclasses:
CsvStringRecordsReader
public class CsvRecordsReader<T> extends java.lang.Object implements org.refcodes.textual.CsvMixin, RecordsReader<T>
TheCsvRecordsReader
is an implementation of theRecords
interface and provides functionality to parse CSV input streams.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.refcodes.textual.CsvEscapeModeAccessor
org.refcodes.textual.CsvEscapeModeAccessor.CsvEscapeModeBuilder<B extends org.refcodes.textual.CsvEscapeModeAccessor.CsvEscapeModeBuilder<?>>, org.refcodes.textual.CsvEscapeModeAccessor.CsvEscapeModeMutator, org.refcodes.textual.CsvEscapeModeAccessor.CsvEscapeModeProperty
-
Nested classes/interfaces inherited from interface org.refcodes.mixin.DelimiterAccessor
org.refcodes.mixin.DelimiterAccessor.DelimiterBuilder<B extends org.refcodes.mixin.DelimiterAccessor.DelimiterBuilder<B>>, org.refcodes.mixin.DelimiterAccessor.DelimiterMutator, org.refcodes.mixin.DelimiterAccessor.DelimiterProperty
-
Nested classes/interfaces inherited from interface org.refcodes.tabular.HeaderAccessor
HeaderAccessor.HeaderBuilder<T extends HeaderAccessor.HeaderBuilder<?>>, HeaderAccessor.HeaderMutator<T>, HeaderAccessor.HeaderProperty<T>
-
-
Constructor Summary
Constructors Modifier Constructor Description CsvRecordsReader(ColumnFactory<T> aColumnFactory, java.io.File aCsvFile)
Constructs aCsvRecordsReader
with the given parameters.CsvRecordsReader(ColumnFactory<T> aColumnFactory, java.io.File aCsvFile, boolean isStrict)
Constructs aCsvRecordsReader
with the given parameters.CsvRecordsReader(ColumnFactory<T> aColumnFactory, java.io.File aCsvFile, char aCsvSeparator)
Constructs aCsvRecordsReader
with the given parameters.CsvRecordsReader(ColumnFactory<T> aColumnFactory, java.io.File aCsvFile, char aCsvSeparator, boolean isStrict)
Constructs aCsvRecordsReader
with the given parameters.CsvRecordsReader(ColumnFactory<T> aColumnFactory, java.io.InputStream aCsvInputStream)
Constructs aCsvRecordsReader
with the given parameters.CsvRecordsReader(ColumnFactory<T> aColumnFactory, java.io.InputStream aCsvInputStream, boolean isStrict)
Constructs aCsvRecordsReader
with the given parameters.CsvRecordsReader(ColumnFactory<T> aColumnFactory, java.io.InputStream aCsvInputStream, char aCsvDelimiter)
Constructs aCsvRecordsReader
with the given parameters.CsvRecordsReader(ColumnFactory<T> aColumnFactory, java.io.InputStream aCsvInputStream, char aCsvDelimiter, boolean isStrict)
Constructs aCsvRecordsReader
with the given parameters.CsvRecordsReader(Header<T> aHeader, java.io.File aCsvFile)
Constructs aCsvRecordsReader
with the given parameters.CsvRecordsReader(Header<T> aHeader, java.io.File aCsvFile, boolean isStrict)
Constructs aCsvRecordsReader
with the given parameters.CsvRecordsReader(Header<T> aHeader, java.io.File aCsvFile, char aCsvSeparator)
Constructs aCsvRecordsReader
with the given parameters.CsvRecordsReader(Header<T> aHeader, java.io.File aCsvFile, char aCsvSeparator, boolean isStrict)
Constructs aCsvRecordsReader
with the given parameters.CsvRecordsReader(Header<T> aHeader, java.io.InputStream aCsvInputStream)
Constructs aCsvRecordsReader
with the given parameters.CsvRecordsReader(Header<T> aHeader, java.io.InputStream aCsvInputStream, boolean isStrict)
Constructs aCsvRecordsReader
with the given parameters.CsvRecordsReader(Header<T> aHeader, java.io.InputStream aCsvInputStream, char aCsvDelimiter)
Constructs aCsvRecordsReader
with the given parameters.CsvRecordsReader(Header<T> aHeader, java.io.InputStream aCsvInputStream, char aCsvDelimiter, boolean isStrict)
Constructs aCsvRecordsReader
with the given parameters.protected
CsvRecordsReader(Header<T> aHeader, ColumnFactory<T> aColumnFactory, java.io.InputStream aCsvInputStream, char aCsvDelimiter, boolean isStrict)
Constructs aCsvRecordsReader
with the given parameters.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearCommentPrefixes()
void
close()
java.lang.String[]
getCommentPrefixes()
org.refcodes.textual.CsvEscapeMode
getCsvEscapeMode()
char
getDelimiter()
long
getErroneousRecordCount()
Gets the erroneous record count.Header<T>
getHeader()
Retrieves theHeader
property.boolean
hasNext()
boolean
isTrim()
Record<T>
next()
Header<T>
readHeader()
Creates aHeader
from the next line to be read .java.lang.String[]
readNext()
Reads the next line from the (standard) input (stream or file) and returns an array of itsString
representation.void
remove()
void
setCommentPrefixes(java.lang.String... aCommentPrefixes)
void
setCsvEscapeMode(org.refcodes.textual.CsvEscapeMode aCsvEscapeMode)
void
setDelimiter(char aCsvDelimiter)
void
setTrim(boolean isTrim)
java.lang.String
skipHeader()
Skips the next line to be read.protected static java.lang.String
toFileNameFromZip(java.lang.String aZipFileName)
Truncates the ".zip" suffix from the filename and returns the result.protected static java.io.InputStream
toInputStream(java.io.File aFile)
Returns anInputStream
from the providedFile
.org.refcodes.textual.CsvMixin
withCommentPrefixes(java.lang.String... aCommentPrefixes)
CsvRecordsReader<T>
withCsvEscapeMode(org.refcodes.textual.CsvEscapeMode aCsvEscapeMode)
CsvRecordsReader<T>
withDelimiter(char aCsvDelimiter)
CsvRecordsReader<T>
withTrim(boolean isTrimRecords)
-
-
-
Constructor Detail
-
CsvRecordsReader
public CsvRecordsReader(Header<T> aHeader, java.io.File aCsvFile) throws java.io.FileNotFoundException, java.io.IOException, java.util.zip.ZipException
Constructs aCsvRecordsReader
with the given parameters. InternallyColumn
instances are generated according to the keys found in the CSV top line. TheColumn
instances are required to convert the CSV line values. If aHeader
is provided, then theHeader
is used for generating theColumn
instances instead of the top line of the CSV file.- Parameters:
aHeader
- TheHeader
to use when parsing the lines retrieved from theInputStream
.aCsvFile
- The CSVFile
which to parse.- Throws:
java.io.FileNotFoundException
- the file not found exceptionjava.io.IOException
- in case there were problems working with the givenFile
.java.util.zip.ZipException
- the zip exception
-
CsvRecordsReader
public CsvRecordsReader(Header<T> aHeader, java.io.File aCsvFile, char aCsvSeparator) throws java.io.FileNotFoundException, java.io.IOException, java.util.zip.ZipException
Constructs aCsvRecordsReader
with the given parameters. InternallyColumn
instances are generated according to the keys found in the CSV top line. TheColumn
instances are required to convert the CSV line values. If aHeader
is provided, then theHeader
is used for generating theColumn
instances instead of the top line of the CSV file.- Parameters:
aHeader
- TheHeader
to use when parsing the lines retrieved from theInputStream
.aCsvFile
- The CSVFile
which to parse.aCsvSeparator
- The delimiter being expected for the CSV input stream.- Throws:
java.io.FileNotFoundException
- the file not found exceptionjava.io.IOException
- in case there were problems working with the givenFile
.java.util.zip.ZipException
- the zip exception
-
CsvRecordsReader
public CsvRecordsReader(Header<T> aHeader, java.io.File aCsvFile, boolean isStrict) throws java.io.FileNotFoundException, java.io.IOException, java.util.zip.ZipException
Constructs aCsvRecordsReader
with the given parameters. InternallyColumn
instances are generated according to the keys found in the CSV top line. TheColumn
instances are required to convert the CSV line values. If aHeader
is provided, then theHeader
is used for generating theColumn
instances instead of the top line of the CSV file.- Parameters:
aHeader
- TheHeader
to use when parsing the lines retrieved from theInputStream
.aCsvFile
- The CSVFile
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 countgetErroneousRecordCount()
is incremented by each erroneousRecord
.- Throws:
java.io.FileNotFoundException
- the file not found exceptionjava.io.IOException
- in case there were problems working with the givenFile
.java.util.zip.ZipException
- the zip exception
-
CsvRecordsReader
public CsvRecordsReader(Header<T> aHeader, java.io.File aCsvFile, char aCsvSeparator, boolean isStrict) throws java.io.FileNotFoundException, java.io.IOException, java.util.zip.ZipException
Constructs aCsvRecordsReader
with the given parameters. InternallyColumn
instances are generated according to the keys found in the CSV top line. TheColumn
instances are required to convert the CSV line values. If aHeader
is provided, then theHeader
is used for generating theColumn
instances instead of the top line of the CSV file.- Parameters:
aHeader
- TheHeader
to use when parsing the lines retrieved from theInputStream
.aCsvFile
- The CSVFile
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 countgetErroneousRecordCount()
is incremented by each erroneousRecord
.- Throws:
java.io.FileNotFoundException
- the file not found exceptionjava.io.IOException
- in case there were problems working with the givenFile
.java.util.zip.ZipException
- the zip exception
-
CsvRecordsReader
public CsvRecordsReader(ColumnFactory<T> aColumnFactory, java.io.File aCsvFile) throws java.io.FileNotFoundException, java.io.IOException, java.util.zip.ZipException
Constructs aCsvRecordsReader
with the given parameters. This constructor supports aColumnFactory
for creatingColumn
instance according to the keys found in the CSV top line. TheColumn
instances are required to convert the CSV line values from the storage format to the actual required type.- Parameters:
aColumnFactory
- AColumnFactory
to be used to generateColumn
instances from the top line of the CSF file, required for parsing the CSV lines and converting them toRecord
instances.aCsvFile
- The CSVFile
which to parse.- Throws:
java.io.FileNotFoundException
- the file not found exceptionjava.io.IOException
- in case there were problems working with the givenFile
.java.util.zip.ZipException
- the zip exception
-
CsvRecordsReader
public CsvRecordsReader(ColumnFactory<T> aColumnFactory, java.io.File aCsvFile, char aCsvSeparator) throws java.io.FileNotFoundException, java.io.IOException, java.util.zip.ZipException
Constructs aCsvRecordsReader
with the given parameters. This constructor supports aColumnFactory
for creatingColumn
instance according to the keys found in the CSV top line. TheColumn
instances are required to convert the CSV line values from the storage format to the actual required type.- Parameters:
aColumnFactory
- AColumnFactory
to be used to generateColumn
instances from the top line of the CSF file, required for parsing the CSV lines and converting them toRecord
instances.aCsvFile
- The CSVFile
which to parse.aCsvSeparator
- The delimiter being expected for the CSV input stream.- Throws:
java.io.FileNotFoundException
- the file not found exceptionjava.io.IOException
- in case there were problems working with the givenFile
.java.util.zip.ZipException
- the zip exception
-
CsvRecordsReader
public CsvRecordsReader(ColumnFactory<T> aColumnFactory, java.io.File aCsvFile, boolean isStrict) throws java.io.FileNotFoundException, java.io.IOException, java.util.zip.ZipException
Constructs aCsvRecordsReader
with the given parameters. This constructor supports aColumnFactory
for creatingColumn
instance according to the keys found in the CSV top line. TheColumn
instances are required to convert the CSV line values from the storage format to the actual required type.- Parameters:
aColumnFactory
- AColumnFactory
to be used to generateColumn
instances from the top line of the CSF file, required for parsing the CSV lines and converting them toRecord
instances.aCsvFile
- The CSVFile
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 countgetErroneousRecordCount()
is incremented by each erroneousRecord
.- Throws:
java.io.FileNotFoundException
- the file not found exceptionjava.io.IOException
- in case there were problems working with the givenFile
.java.util.zip.ZipException
- the zip exception
-
CsvRecordsReader
public CsvRecordsReader(ColumnFactory<T> aColumnFactory, java.io.File aCsvFile, char aCsvSeparator, boolean isStrict) throws java.io.FileNotFoundException, java.io.IOException, java.util.zip.ZipException
Constructs aCsvRecordsReader
with the given parameters. This constructor supports aColumnFactory
for creatingColumn
instance according to the keys found in the CSV top line. TheColumn
instances are required to convert the CSV line values from the storage format to the actual required type.- Parameters:
aColumnFactory
- AColumnFactory
to be used to generateColumn
instances from the top line of the CSF file, required for parsing the CSV lines and converting them toRecord
instances.aCsvFile
- The CSVFile
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 countgetErroneousRecordCount()
is incremented by each erroneousRecord
.- Throws:
java.io.FileNotFoundException
- the file not found exceptionjava.io.IOException
- in case there were problems working with the givenFile
.java.util.zip.ZipException
- the zip exception
-
CsvRecordsReader
public CsvRecordsReader(Header<T> aHeader, java.io.InputStream aCsvInputStream) throws java.io.IOException
Constructs aCsvRecordsReader
with the given parameters. InternallyColumn
instances are generated according to the keys found in the CSV top line. TheColumn
instances are required to convert the CSV line values. If aHeader
is provided, then theHeader
is used for generating theColumn
instances instead of the top line of the CSV file.- Parameters:
aHeader
- TheHeader
to use when parsing the lines retrieved from theInputStream
.aCsvInputStream
- The CSVInputStream
which to parse.- Throws:
java.io.IOException
- in case there were problems working with the givenInputStream
.
-
CsvRecordsReader
public CsvRecordsReader(Header<T> aHeader, java.io.InputStream aCsvInputStream, boolean isStrict) throws java.io.IOException
Constructs aCsvRecordsReader
with the given parameters. InternallyColumn
instances are generated according to the keys found in the CSV top line. TheColumn
instances are required to convert the CSV line values. If aHeader
is provided, then theHeader
is used for generating theColumn
instances instead of the top line of the CSV file.- Parameters:
aHeader
- TheHeader
to use when parsing the lines retrieved from theInputStream
.aCsvInputStream
- The CSVInputStream
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 countgetErroneousRecordCount()
is incremented by each erroneousRecord
.- Throws:
java.io.IOException
- in case there were problems working with the givenInputStream
.
-
CsvRecordsReader
public CsvRecordsReader(Header<T> aHeader, java.io.InputStream aCsvInputStream, char aCsvDelimiter) throws java.io.IOException
Constructs aCsvRecordsReader
with the given parameters. InternallyColumn
instances are generated according to the keys found in the CSV top line. TheColumn
instances are required to convert the CSV line values. If aHeader
is provided, then theHeader
is used for generating theColumn
instances instead of the top line of the CSV file.- Parameters:
aHeader
- TheHeader
to use when parsing the lines retrieved from theInputStream
.aCsvInputStream
- The CSVInputStream
which to parse.aCsvDelimiter
- The delimiter being expected for the CSV input stream.- Throws:
java.io.IOException
- in case there were problems working with the givenInputStream
.
-
CsvRecordsReader
public CsvRecordsReader(Header<T> aHeader, java.io.InputStream aCsvInputStream, char aCsvDelimiter, boolean isStrict) throws java.io.IOException
Constructs aCsvRecordsReader
with the given parameters. InternallyColumn
instances are generated according to the keys found in the CSV top line. TheColumn
instances are required to convert the CSV line values. If aHeader
is provided, then theHeader
is used for generating theColumn
instances instead of the top line of the CSV file.- Parameters:
aHeader
- TheHeader
to use when parsing the lines retrieved from theInputStream
.aCsvInputStream
- The CSVInputStream
which to parse.aCsvDelimiter
- 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 countgetErroneousRecordCount()
is incremented by each erroneousRecord
.- Throws:
java.io.IOException
- in case there were problems working with the givenInputStream
.
-
CsvRecordsReader
public CsvRecordsReader(ColumnFactory<T> aColumnFactory, java.io.InputStream aCsvInputStream) throws java.io.IOException
Constructs aCsvRecordsReader
with the given parameters. This constructor supports aColumnFactory
for creatingColumn
instance according to the keys found in the CSV top line. TheColumn
instances are required to convert the CSV line values from the storage format to the actual required type.- Parameters:
aColumnFactory
- AColumnFactory
to be used to generateColumn
instances from the top line of the CSF file, required for parsing the CSV lines and converting them toRecord
instances.aCsvInputStream
- The CSVInputStream
which to parse.- Throws:
java.io.IOException
- in case there were problems working with the givenInputStream
.
-
CsvRecordsReader
public CsvRecordsReader(ColumnFactory<T> aColumnFactory, java.io.InputStream aCsvInputStream, boolean isStrict) throws java.io.IOException
Constructs aCsvRecordsReader
with the given parameters. This constructor supports aColumnFactory
for creatingColumn
instance according to the keys found in the CSV top line. TheColumn
instances are required to convert the CSV line values from the storage format to the actual required type.- Parameters:
aColumnFactory
- AColumnFactory
to be used to generateColumn
instances from the top line of the CSF file, required for parsing the CSV lines and converting them toRecord
instances.aCsvInputStream
- The CSVInputStream
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 countgetErroneousRecordCount()
is incremented by each erroneousRecord
.- Throws:
java.io.IOException
- in case there were problems working with the givenInputStream
.
-
CsvRecordsReader
public CsvRecordsReader(ColumnFactory<T> aColumnFactory, java.io.InputStream aCsvInputStream, char aCsvDelimiter) throws java.io.IOException
Constructs aCsvRecordsReader
with the given parameters. This constructor supports aColumnFactory
for creatingColumn
instance according to the keys found in the CSV top line. TheColumn
instances are required to convert the CSV line values from the storage format to the actual required type.- Parameters:
aColumnFactory
- AColumnFactory
to be used to generateColumn
instances from the top line of the CSF file, required for parsing the CSV lines and converting them toRecord
instances.aCsvInputStream
- The CSVInputStream
which to parse.aCsvDelimiter
- The delimiter being expected for the CSV input stream.- Throws:
java.io.IOException
- in case there were problems working with the givenInputStream
.
-
CsvRecordsReader
public CsvRecordsReader(ColumnFactory<T> aColumnFactory, java.io.InputStream aCsvInputStream, char aCsvDelimiter, boolean isStrict) throws java.io.IOException
Constructs aCsvRecordsReader
with the given parameters. This constructor supports aColumnFactory
for creatingColumn
instance according to the keys found in the CSV top line. TheColumn
instances are required to convert the CSV line values from the storage format to the actual required type.- Parameters:
aColumnFactory
- AColumnFactory
to be used to generateColumn
instances from the top line of the CSF file, required for parsing the CSV lines and converting them toRecord
instances.aCsvInputStream
- The CSVInputStream
which to parse.aCsvDelimiter
- 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 countgetErroneousRecordCount()
is incremented by each erroneousRecord
.- Throws:
java.io.IOException
- in case there were problems working with the givenInputStream
.
-
CsvRecordsReader
protected CsvRecordsReader(Header<T> aHeader, ColumnFactory<T> aColumnFactory, java.io.InputStream aCsvInputStream, char aCsvDelimiter, boolean isStrict) throws java.io.IOException
Constructs aCsvRecordsReader
with the given parameters. This constructor supports aColumnFactory
for creatingColumn
instance according to the keys found in the CSV top line. TheColumn
instances are required to convert the CSV line values from the storage format to the actual required type. If aHeader
is provided, then theHeader
is used for generating theColumn
instances instead of the top line of the CSV file.- Parameters:
aHeader
- TheHeader
to use when parsing the lines retrieved from theInputStream
.aColumnFactory
- AColumnFactory
to be used to generateColumn
instances from the top line of the CSF file, required for parsing the CSV lines and converting them toRecord
instances.aCsvInputStream
- The CSVInputStream
which to parse.aCsvDelimiter
- 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 countgetErroneousRecordCount()
is incremented by each erroneousRecord
.- Throws:
java.io.IOException
- in case there were problems working with the givenInputStream
.
-
-
Method Detail
-
readHeader
public Header<T> readHeader() throws java.io.IOException
Creates aHeader
from the next line to be read .- Specified by:
readHeader
in interfaceRecordsReader<T>
- Returns:
- Returns the
Header
being read. - Throws:
java.io.IOException
- thrown in case reading from IO failed.
-
skipHeader
public java.lang.String skipHeader() throws java.io.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).- Specified by:
skipHeader
in interfaceRecordsReader<T>
- Returns:
- The line being skipped.
- Throws:
java.io.IOException
- thrown in case if IO problems.
-
hasNext
public boolean hasNext()
- Specified by:
hasNext
in interfacejava.util.Iterator<T>
-
readNext
public java.lang.String[] readNext()
Reads the next line from the (standard) input (stream or file) and returns an array of itsString
representation.- Specified by:
readNext
in interfaceRecordsReader<T>
- Returns:
- The
String
array representation of the nextRecord
instance read.
-
remove
public void remove()
- Specified by:
remove
in interfacejava.util.Iterator<T>
-
getHeader
public Header<T> getHeader()
Retrieves theHeader
property.- Specified by:
getHeader
in interfaceHeaderAccessor<T>
- Returns:
- The
Header
being stored by this property.
-
setCommentPrefixes
public void setCommentPrefixes(java.lang.String... aCommentPrefixes)
- Specified by:
setCommentPrefixes
in interfaceorg.refcodes.textual.CsvMixin
-
getCommentPrefixes
public java.lang.String[] getCommentPrefixes()
- Specified by:
getCommentPrefixes
in interfaceorg.refcodes.textual.CsvMixin
-
clearCommentPrefixes
public void clearCommentPrefixes()
- Specified by:
clearCommentPrefixes
in interfaceorg.refcodes.textual.CsvMixin
-
withCommentPrefixes
public org.refcodes.textual.CsvMixin withCommentPrefixes(java.lang.String... aCommentPrefixes)
- Specified by:
withCommentPrefixes
in interfaceorg.refcodes.textual.CsvMixin
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Throws:
java.io.IOException
-
getCsvEscapeMode
public org.refcodes.textual.CsvEscapeMode getCsvEscapeMode()
- Specified by:
getCsvEscapeMode
in interfaceorg.refcodes.textual.CsvEscapeModeAccessor
-
isTrim
public boolean isTrim()
- Specified by:
isTrim
in interfaceorg.refcodes.mixin.TrimAccessor
-
getDelimiter
public char getDelimiter()
- Specified by:
getDelimiter
in interfaceorg.refcodes.mixin.DelimiterAccessor
-
setTrim
public void setTrim(boolean isTrim)
- Specified by:
setTrim
in interfaceorg.refcodes.mixin.TrimAccessor.TrimMutator
-
setDelimiter
public void setDelimiter(char aCsvDelimiter)
- Specified by:
setDelimiter
in interfaceorg.refcodes.mixin.DelimiterAccessor.DelimiterMutator
-
withTrim
public CsvRecordsReader<T> withTrim(boolean isTrimRecords)
- Specified by:
withTrim
in interfaceorg.refcodes.mixin.TrimAccessor.TrimBuilder<T>
-
withCsvEscapeMode
public CsvRecordsReader<T> withCsvEscapeMode(org.refcodes.textual.CsvEscapeMode aCsvEscapeMode)
- Specified by:
withCsvEscapeMode
in interfaceorg.refcodes.textual.CsvEscapeModeAccessor.CsvEscapeModeBuilder<T>
-
withDelimiter
public CsvRecordsReader<T> withDelimiter(char aCsvDelimiter)
- Specified by:
withDelimiter
in interfaceorg.refcodes.mixin.DelimiterAccessor.DelimiterBuilder<T>
-
setCsvEscapeMode
public void setCsvEscapeMode(org.refcodes.textual.CsvEscapeMode aCsvEscapeMode)
- Specified by:
setCsvEscapeMode
in interfaceorg.refcodes.textual.CsvEscapeModeAccessor.CsvEscapeModeMutator
-
getErroneousRecordCount
public long getErroneousRecordCount()
Gets the erroneous record count.- Specified by:
getErroneousRecordCount
in interfaceRecordsReader<T>
- Returns:
- the erroneous record count
-
toInputStream
protected static java.io.InputStream toInputStream(java.io.File aFile) throws java.util.zip.ZipException, java.io.IOException, java.io.FileNotFoundException
Returns anInputStream
from the providedFile
. In case the file points to a ZIP compressed file, then the uncompressed data is provided by theInputStream
.- Parameters:
aFile
- TheFile
for which to get theInputStream
.- Returns:
- An
InputStream
, in case of a ZIP compressedFile
, an uncompressedInputStream
is returned. - Throws:
java.util.zip.ZipException
- in case there were problems when accessing the ZIP compressedFile
.java.io.IOException
- in case there were problems working with theFile
.java.io.FileNotFoundException
- in case there was none suchFile
found.
-
toFileNameFromZip
protected static java.lang.String toFileNameFromZip(java.lang.String aZipFileName)
Truncates the ".zip" suffix from the filename and returns the result. For example a file with name "log-2023-07-12.txt.zip" results in "log-2023-07-12.txt".- Parameters:
aZipFileName
- The file name of the ZIP file for which to get the "inner" file name.- Returns:
- The "inner" file name if the file suffix was ".zip", else null.
-
-