|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectolg.csv.base.csv.CSVReader
public final class CSVReader
CSV Reader. CSV Implementation of IReader.
Field Summary | |
---|---|
private String |
charset
Read file Charset. |
private String |
ddelimiter
Double Delimiter. |
private char |
delimiter
Cell delimiter. |
private int |
fieldIndex
Current cell number. |
private FileInputStream |
fileInputStream
the CSV file input stream. |
private static org.slf4j.Logger |
LOGGER
the class Logger. |
private CharSearchReader |
reader
the char search reader applied on the stream. |
private int |
recordIndex
current row number. |
private int |
rowSize
Read Row size. |
private char |
separator
cell separator. |
private boolean |
skipEmptyCell
if true the returned rows will only contain not empty cells. |
private boolean |
withHeaders
to skip headers. |
Constructor Summary | |
---|---|
|
CSVReader(File file,
CSVSettings settings)
Constructor with custom settings. |
protected |
CSVReader(File file,
CSVSettings settings,
int bufSize)
Constructor with custom settings. |
|
CSVReader(InputStream input,
CSVSettings settings)
Constructor with custom settings. |
Method Summary | |
---|---|
void |
close()
Closes this stream and catches and logs IOException. if the parent stream is provided and passed to CSVReader constructor by user, user must close it (closes what you opens!) |
private String |
getFieldDelimiterCase()
Get next field value in case field has delimiters around. |
private String |
getFieldNoDelimiterCase()
Get next field value when a field has no delimiters around. |
boolean |
hasNext()
|
boolean |
isWithHeaders()
Indicates the CSV file has a header line. |
Row |
next()
|
private Cell |
readCell()
Read a cell. |
void |
remove()
CSVReader throws an UnsupportedOperationException. |
private Row |
setNext()
Returns next row. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final org.slf4j.Logger LOGGER
private boolean skipEmptyCell
private char separator
private char delimiter
private String ddelimiter
private String charset
private boolean withHeaders
private int fieldIndex
private int recordIndex
private FileInputStream fileInputStream
private CharSearchReader reader
private int rowSize
Constructor Detail |
---|
public CSVReader(File file, CSVSettings settings) throws IOException
throws UnsupportedCharsetException if charset is not supported.
throws FileNotFoundException if the file does not exist, is a directory rather than a regular file, or for some other reason cannot be opened for reading.
throws IllegalArgumentException if file, CSVSettings, lineSeparator
setting or charsetName setting is null
file
- the file to be read.settings
- the settings.
IOException
- if error occurs on file opening.to see default parameters values
protected CSVReader(File file, CSVSettings settings, int bufSize) throws IOException
throws UnsupportedCharsetException if charset is not supported.
throws FileNotFoundException if the file does not exist, is a directory rather than a regular file, or for some other reason cannot be opened for reading.
file
- the file.settings
- the settingsbufSize
- the buffer size.
IOException
- if error occurs on file opening.to see default parameters values
public CSVReader(InputStream input, CSVSettings settings) throws IOException
throws UnsupportedCharsetException if charset is not supported.
throws IllegalArgumentException if input, CSVSettings or charsetName
setting is null
input
- the streamsettings
- the settings.
IOException
- if error occurs on stream buffering.to see default parameters values
Method Detail |
---|
public boolean isWithHeaders()
isWithHeaders
in interface IReader
public boolean hasNext()
hasNext
in interface Iterator<Row>
public Row next()
next
in interface Iterator<Row>
public void remove()
remove
in interface Iterator<Row>
public void close()
close
in interface Closeable
private Row setNext()
Throws a ReaderException if a CSV constraint is not satisfied.
private Cell readCell() throws IOException
Throws a ReaderException if a CSV constraint is not satisfied.
IOException
- if I/O error occurs on stream reading.private String getFieldDelimiterCase() throws IOException
Throws a ReaderException if a CSV constraint is not satisfied.
IOException
- if I/O error occurs on stream reading.private String getFieldNoDelimiterCase() throws IOException
IOException
- if I/O error occurs on stream reading.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |