public class CsvParser extends Object implements RecordParser
Constructor and Description |
---|
CsvParser(InputStream stream,
String path,
CsvConfiguration config)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
endRecord()
Finalizes current record.
|
void |
fill(BooleanOption option)
Reads the next cell and set the value into the target object.
|
void |
fill(ByteOption option)
Reads the next cell and set the value into the target object.
|
void |
fill(DateOption option)
Reads the next cell and set the value into the target object.
|
void |
fill(DateTimeOption option)
Reads the next cell and set the value into the target object.
|
void |
fill(DecimalOption option)
Reads the next cell and set the value into the target object.
|
void |
fill(DoubleOption option)
Reads the next cell and set the value into the target object.
|
void |
fill(FloatOption option)
Reads the next cell and set the value into the target object.
|
void |
fill(IntOption option)
Reads the next cell and set the value into the target object.
|
void |
fill(LongOption option)
Reads the next cell and set the value into the target object.
|
void |
fill(ShortOption option)
Reads the next cell and set the value into the target object.
|
void |
fill(StringOption option)
Reads the next cell and set the value into the target object.
|
long |
getCurrentLineNumber()
Returns the 1-origin line number where the current record is started.
|
long |
getCurrentRecordNumber()
Returns the 1-origin record number.
|
String |
getPath()
Returns the parsing target path.
|
boolean |
next()
Prepare for reading the next record.
|
public CsvParser(InputStream stream, String path, CsvConfiguration config)
stream
- the source streampath
- the source pathconfig
- current configurationIllegalArgumentException
- if some parameters were null
public boolean next() throws CsvFormatException, IOException
RecordParser
RecordFormatException
.next
in interface RecordParser
true
if the next record exists, or otherwise false
RecordFormatException
- if the record format is something wrongIOException
- if error occurred while reading the head of the next recordCsvFormatException
public String getPath()
public long getCurrentLineNumber()
CR
, LF
, and CRLF
.public long getCurrentRecordNumber()
public void fill(BooleanOption option) throws CsvFormatException, IOException
RecordParser
fill
in interface RecordParser
option
- the target objectRecordFormatException
- if the record format is something wrongIOException
- if error occurred while reading the next cellCsvFormatException
public void fill(ByteOption option) throws CsvFormatException, IOException
RecordParser
fill
in interface RecordParser
option
- the target objectRecordFormatException
- if the record format is something wrongIOException
- if error occurred while reading the next cellCsvFormatException
public void fill(ShortOption option) throws CsvFormatException, IOException
RecordParser
fill
in interface RecordParser
option
- the target objectRecordFormatException
- if the record format is something wrongIOException
- if error occurred while reading the next cellCsvFormatException
public void fill(IntOption option) throws CsvFormatException, IOException
RecordParser
fill
in interface RecordParser
option
- the target objectRecordFormatException
- if the record format is something wrongIOException
- if error occurred while reading the next cellCsvFormatException
public void fill(LongOption option) throws CsvFormatException, IOException
RecordParser
fill
in interface RecordParser
option
- the target objectRecordFormatException
- if the record format is something wrongIOException
- if error occurred while reading the next cellCsvFormatException
public void fill(FloatOption option) throws CsvFormatException, IOException
RecordParser
fill
in interface RecordParser
option
- the target objectRecordFormatException
- if the record format is something wrongIOException
- if error occurred while reading the next cellCsvFormatException
public void fill(DoubleOption option) throws CsvFormatException, IOException
RecordParser
fill
in interface RecordParser
option
- the target objectRecordFormatException
- if the record format is something wrongIOException
- if error occurred while reading the next cellCsvFormatException
public void fill(DecimalOption option) throws CsvFormatException, IOException
RecordParser
fill
in interface RecordParser
option
- the target objectRecordFormatException
- if the record format is something wrongIOException
- if error occurred while reading the next cellCsvFormatException
public void fill(StringOption option) throws CsvFormatException, IOException
RecordParser
fill
in interface RecordParser
option
- the target objectRecordFormatException
- if the record format is something wrongIOException
- if error occurred while reading the next cellCsvFormatException
public void fill(DateOption option) throws CsvFormatException, IOException
RecordParser
0
, this set null
to the target object.fill
in interface RecordParser
option
- the target objectRecordFormatException
- if the record format is something wrongIOException
- if error occurred while reading the next cellCsvFormatException
public void fill(DateTimeOption option) throws CsvFormatException, IOException
RecordParser
0
, this set null
to the target object.fill
in interface RecordParser
option
- the target objectRecordFormatException
- if the record format is something wrongIOException
- if error occurred while reading the next cellCsvFormatException
public void endRecord() throws CsvFormatException, IOException
RecordParser
endRecord
in interface RecordParser
RecordFormatException
- if current record is wrongIOException
- if failed to finalize this recordCsvFormatException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
Copyright © 2011–2019 Asakusa Framework Team. All rights reserved.