public final class CSVRecord
extends java.lang.Object
implements java.io.Serializable, java.lang.Iterable<java.lang.String>
| Modifier and Type | Field and Description |
|---|---|
private long |
characterPosition |
private java.lang.String |
comment
The accumulated comments (if any)
|
private static java.lang.String[] |
EMPTY_STRING_ARRAY |
private java.util.Map<java.lang.String,java.lang.Integer> |
mapping
The column name to index mapping.
|
private long |
recordNumber
The record number.
|
private static long |
serialVersionUID |
private java.lang.String[] |
values
The values of the record
|
| Constructor and Description |
|---|
CSVRecord(java.lang.String[] values,
java.util.Map<java.lang.String,java.lang.Integer> mapping,
java.lang.String comment,
long recordNumber,
long characterPosition) |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
get(java.lang.Enum<?> e)
Returns a value by
Enum. |
java.lang.String |
get(int i)
Returns a value by index.
|
java.lang.String |
get(java.lang.String name)
Returns a value by name.
|
long |
getCharacterPosition()
Returns the start position of this record as a character position in the source stream.
|
java.lang.String |
getComment()
Returns the comment for this record, if any.
|
long |
getRecordNumber()
Returns the number of this record in the parsed CSV file.
|
boolean |
hasComment()
Checks whether this record has a comment, false otherwise.
|
boolean |
isConsistent()
Tells whether the record size matches the header size.
|
boolean |
isMapped(java.lang.String name)
Checks whether a given column is mapped, i.e.
|
boolean |
isSet(java.lang.String name)
Checks whether a given columns is mapped and has a value.
|
java.util.Iterator<java.lang.String> |
iterator()
Returns an iterator over the values of this record.
|
(package private) <M extends java.util.Map<java.lang.String,java.lang.String>> |
putIn(M map)
Puts all values of this record into the given Map.
|
int |
size()
Returns the number of values in this record.
|
private java.util.List<java.lang.String> |
toList()
Converts the values to a List.
|
java.util.Map<java.lang.String,java.lang.String> |
toMap()
Copies this record into a new Map.
|
java.lang.String |
toString()
Returns a string representation of the contents of this record.
|
(package private) java.lang.String[] |
values() |
private static final java.lang.String[] EMPTY_STRING_ARRAY
private static final long serialVersionUID
private final long characterPosition
private final java.lang.String comment
private final java.util.Map<java.lang.String,java.lang.Integer> mapping
private final long recordNumber
private final java.lang.String[] values
CSVRecord(java.lang.String[] values,
java.util.Map<java.lang.String,java.lang.Integer> mapping,
java.lang.String comment,
long recordNumber,
long characterPosition)
public java.lang.String get(java.lang.Enum<?> e)
Enum.e - an enumpublic java.lang.String get(int i)
i - a column index (0-based)public java.lang.String get(java.lang.String name)
name - the name of the column to be retrieved.CSVFormat.getNullString().java.lang.IllegalStateException - if no header mapping was providedjava.lang.IllegalArgumentException - if name is not mapped or if the record is inconsistentisConsistent(),
CSVFormat.withNullString(String)public long getCharacterPosition()
public java.lang.String getComment()
public long getRecordNumber()
ATTENTION: If your CSV input has multi-line values, the returned number does not correspond to the current line number of the parser that created this record.
CSVParser.getCurrentLineNumber()public boolean isConsistent()
Returns true if the sizes for this record match and false if not. Some programs can export files that fail this test but still produce parsable files.
public boolean hasComment()
public boolean isMapped(java.lang.String name)
name - the name of the column to be retrieved.public boolean isSet(java.lang.String name)
name - the name of the column to be retrieved.public java.util.Iterator<java.lang.String> iterator()
iterator in interface java.lang.Iterable<java.lang.String><M extends java.util.Map<java.lang.String,java.lang.String>> M putIn(M map)
map - The Map to populate.public int size()
private java.util.List<java.lang.String> toList()
public java.util.Map<java.lang.String,java.lang.String> toMap()
public java.lang.String toString()
Arrays.toString(Object[]).toString in class java.lang.Objectjava.lang.String[] values()