The field values are never null. Empty fields are represented as empty strings.
CSV records are created by CsvReader or IndexedCsvReader.
CsvReader, IndexedCsvReader
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final boolean | comment
If the record is a commented record. |
| pack-priv final String[] | fields
The fields this record is composed of. |
| pack-priv final long | startingLineNumber
The starting line number (starting with 1). |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public String | Returns: field value, nevernullindex of the field to return index)Retrieves the value of a field based on its index, with indexing starting from 0. |
| public int | |
| public List | Returns: all fields of this record, nevernullRetrieves all fields of this record as an unmodifiable list. |
| public long | Returns: the starting line number of this record, starting from 1Provides the line number at which this record originated, starting from 1. |
| public boolean | Returns: true if the record is a commented recordIndicates whether the record is a commented record. |
| public String |
| comment | back to summary |
|---|---|
| pack-priv final boolean comment If the record is a commented record.
| |
| fields | back to summary |
|---|---|
| pack-priv final String[] fields The fields this record is composed of.
| |
| startingLineNumber | back to summary |
|---|---|
| pack-priv final long startingLineNumber The starting line number (starting with 1).
| |
| CsvRecord | back to summary |
|---|---|
| pack-priv CsvRecord(final long startingLineNumber, final String[] fields, final boolean comment) | |
| getField | back to summary |
|---|---|
| public String getField(final int index) Retrieves the value of a field based on its index, with indexing starting from 0. There is always at least one field, even if the line was empty. If this records holds a comment, the comment is returned by calling this method with index 0. The comment character is not included in the returned value.
| |
| getFieldCount | back to summary |
|---|---|
| public int getFieldCount() Gets the count of fields in this record. The minimum number of fields is 1, even if the line was empty.
| |
| getFields | back to summary |
|---|---|
| public List Retrieves all fields of this record as an unmodifiable list. The returned list has a minimum size of 1, even if the line was empty. For empty lines, the first field is an empty string. | |
| getStartingLineNumber | back to summary |
|---|---|
| public long getStartingLineNumber() Provides the line number at which this record originated, starting from 1. This information is particularly valuable in scenarios involving CSV files containing empty lines as well as multi-line or commented records, where the record number may deviate from the line number. Example: 1 foo,bar
2 foo,"multi
3 line bar"
4 (empty, potentially skipped)
5 #commented record (potentially skipped)
6 "latest
7 record"
The last record (containing the multi-line field "latest\nrecord") would have a starting line number of 6, no matter if empty lines or commented records are skipped or not. A starting offset of 1 is used to be consistent with the line numbers shown of most text editors. Note that this number is only correct if the CSV data was read from the very beginning. If you passed
a
| |
| isComment | back to summary |
|---|---|
| public boolean isComment() Indicates whether the record is a commented record. Retrieve the comment by calling
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non-
| |