public final class CSVRecord
extends java.lang.Object
implements java.io.Serializable, java.lang.Iterable<java.lang.String>
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 |
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.
|
int |
size()
Returns the number of values in this record.
|
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.
|
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 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>
public int size()
public java.util.Map<java.lang.String,java.lang.String> toMap()
public java.lang.String toString()
Arrays.toString(Object[])
.toString
in class java.lang.Object