public class CsvFieldReader extends Object implements FieldReader
FieldReader
for RFC4180 style CSV files.Constructor and Description |
---|
CsvFieldReader(Reader reader,
char fieldSeparator,
char quoteCharacter,
boolean allowLineFeed,
UnaryOperator<CharSequence> transformer)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
CharSequence |
getContent()
Returns the content of the current field.
|
long |
getFieldIndex()
Returns the field index of the current field.
|
long |
getRecordIndex()
Returns the record index of the current field.
|
long |
getRecordLineNumber()
Returns the number of line where the current RECORD starts.
|
boolean |
nextField()
Advances the cursor and returns whether or not the next field exists in the current record.
|
boolean |
nextRecord()
Advances the cursor and returns whether or not the next record exists.
|
void |
rewindFields()
Rewinds the cursor to the head of the current record.
|
public CsvFieldReader(Reader reader, char fieldSeparator, char quoteCharacter, boolean allowLineFeed, UnaryOperator<CharSequence> transformer)
reader
- the source text readerfieldSeparator
- the field separator characterquoteCharacter
- the quote characterallowLineFeed
- true
to allow LF in field, otherwise false
transformer
- the line content transformer (nullable)public boolean nextRecord() throws IOException
FieldReader
FieldReader.getContent()
result object.nextRecord
in interface FieldReader
true
if the next record exists, otherwise false
IOException
- if I/O error occurred while reading the next recordpublic boolean nextField() throws IOException
FieldReader
FieldReader.getContent()
result object.nextField
in interface FieldReader
true
if the next field exists, otherwise false
IOException
- if I/O error occurred while reading the next fieldpublic void rewindFields() throws IOException
FieldReader
rewindFields
in interface FieldReader
IOException
- if I/O error occurred while rewinding fieldspublic CharSequence getContent()
FieldReader
getContent
in interface FieldReader
null
if this represents NULL
public long getRecordLineNumber()
FieldReader
getRecordLineNumber
in interface FieldReader
-1
if it is not surepublic long getRecordIndex()
FieldReader
getRecordIndex
in interface FieldReader
-1
if it is not surepublic long getFieldIndex()
FieldReader
getFieldIndex
in interface FieldReader
-1
if it is not surepublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
Copyright © 2011–2019 Asakusa Framework Team. All rights reserved.