public final class CSVRecord extends Object implements Serializable, Iterable<String>
Modifier and Type | Method and Description |
---|---|
String |
get(Enum<?> e)
Returns a value by
Enum . |
String |
get(int i)
Returns a value by index.
|
String |
get(String name)
Returns a value by name.
|
long |
getCharacterPosition()
Returns the start position of this record as a character position in the source stream.
|
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(String name)
Checks whether a given column is mapped, i.e.
|
boolean |
isSet(String name)
Checks whether a given columns is mapped and has a value.
|
Iterator<String> |
iterator()
Returns an iterator over the values of this record.
|
int |
size()
Returns the number of values in this record.
|
Map<String,String> |
toMap()
Copies this record into a new Map.
|
String |
toString()
Returns a string representation of the contents of this record.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
forEach, spliterator
public String get(Enum<?> e)
Enum
.e
- an enumpublic String get(int i)
i
- a column index (0-based)public String get(String name)
name
- the name of the column to be retrieved.CSVFormat.getNullString()
.IllegalStateException
- if no header mapping was providedIllegalArgumentException
- if name
is not mapped or if the record is inconsistentisConsistent()
,
CSVFormat.withNullString(String)
public long getCharacterPosition()
public 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(String name)
name
- the name of the column to be retrieved.public boolean isSet(String name)
name
- the name of the column to be retrieved.public int size()
public Map<String,String> toMap()
public String toString()
Arrays.toString(Object[])
.Copyright © 2017. All rights reserved.