public class Csv extends ProxiedList<CsvRow>
List<String>
for convenience reasons.
The first row is referenced as header row and CsvRow
instances
allow to retrieve their values by the column's CSV header value.
Instances of this class can be marked unmodifiable using
unmodifiable()
. Afterwards applying modifying actions on that
instance results in an UnsupportedOperationException
.
Modifier and Type | Field and Description |
---|---|
static char |
DEFAULT_ESCAPER
The default CSV escape character
|
static char |
DEFAULT_SEPARATOR
The default CSV separator character
|
Constructor and Description |
---|
Csv()
This class represents CSV data, consisting of rows of values, implementing
List<String> for convenience reasons. |
Csv(char separator,
char escaper)
This class represents CSV data, consisting of rows of values, implementing
List<String> for convenience reasons. |
Csv(int initialCapacity)
This class represents CSV data, consisting of rows of values, implementing
List<String> for convenience reasons. |
Csv(int initialCapacity,
char separator,
char escaper)
This class represents CSV data, consisting of rows of values, implementing
List<String> for convenience reasons. |
Csv(List<? extends List<String>> data)
This class represents CSV data, consisting of rows of values, implementing
List<String> for convenience reasons. |
Csv(List<? extends List<String>> data,
char separator,
char escaper)
This class represents CSV data, consisting of rows of values, implementing
List<String> for convenience reasons. |
Modifier and Type | Method and Description |
---|---|
boolean |
add(CsvRow element) |
void |
add(int index,
CsvRow element) |
boolean |
add(List<String> element)
Adds the specified CSV row to the this CSV object.
|
boolean |
addAll(Collection<? extends CsvRow> collection) |
boolean |
addAll(int index,
Collection<? extends CsvRow> collection) |
boolean |
addAllList(Collection<? extends List<String>> collection)
Adds all of the CSV rows in
collection to this CSV object. |
CsvRow |
get(int index) |
char |
getEscaper()
The instances CSV escape character
|
List<String> |
getHeaders()
Returns the headers of this CSV object.
|
char |
getSeparator()
The instances CSV separator character
|
boolean |
isModifiable()
Flag specifying if this instance can be modified
|
static Csv |
parse(Reader reader,
char separator,
char escaper)
Parses the CSV data given by
reader , starting at the current
position. |
CsvRow |
remove(int index) |
CsvRow |
set(int index,
CsvRow element) |
String |
toString()
Returns a valid CSV string representation of this object using the instances
separator and escaper.
|
String |
toString(char separator,
char escaper)
Returns a valid CSV string representation of this object using
separator and escaper . |
Csv |
unmodifiable()
Marks the CSV object as unmodifiable
|
getWrappedForRead, getWrappedIfModifiable, indexOf, lastIndexOf, listIterator, listIterator, subList
clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, replaceAll, retainAll, size, sort, spliterator, toArray, toArray
parallelStream, removeIf, stream
public static final char DEFAULT_ESCAPER
public static final char DEFAULT_SEPARATOR
public Csv()
List<String>
for convenience reasons.
The first row is referenced as header row and CsvRow
instances
allow to retrieve their values by the column's CSV header value.
public Csv(char separator, char escaper)
List<String>
for convenience reasons.
The first row is referenced as header row and CsvRow
instances
allow to retrieve their values by the column's CSV header value.
separator
- the instances CSV separator characterescaper
- the instances CSV escape characterpublic Csv(int initialCapacity)
List<String>
for convenience reasons.
The first row is referenced as header row and CsvRow
instances
allow to retrieve their values by the column's CSV header value.
initialCapacity
- an initial capacity of the internal listIllegalArgumentException
- if the specified initial capacity is
negativepublic Csv(int initialCapacity, char separator, char escaper)
List<String>
for convenience reasons.
The first row is referenced as header row and CsvRow
instances
allow to retrieve their values by the column's CSV header value.
initialCapacity
- an initial capacity of the internal listseparator
- the instances CSV separator characterescaper
- the instances CSV escape characterIllegalArgumentException
- if the specified initial capacity is
negativepublic Csv(List<? extends List<String>> data)
List<String>
for convenience reasons.
The first row is referenced as header row and CsvRow
instances
allow to retrieve their values by the column's CSV header value.
data
- a collection containing CSV rows to be addedpublic Csv(List<? extends List<String>> data, char separator, char escaper)
List<String>
for convenience reasons.
The first row is referenced as header row and CsvRow
instances
allow to retrieve their values by the column's CSV header value.
data
- a collection containing CSV rows to be addedseparator
- the instances CSV separator characterescaper
- the instances CSV escape characterpublic static Csv parse(Reader reader, char separator, char escaper) throws IOException
reader
, starting at the current
position.reader
- a Reader
as CSV data inputseparator
- the CSV separator characterescaper
- the CSV escaping characterIllegalArgumentException
- on illegal separator
or
escaper
valueIOException
- if an I/O error occurspublic boolean add(@Nullable CsvRow element)
add
in interface Collection<CsvRow>
add
in interface List<CsvRow>
add
in class ProxiedCollection<CsvRow>
public boolean add(List<String> element)
element
- the CSV row to be addedtrue
UnsupportedOperationException
- if this CSV object is unmodifiablepublic void add(int index, @Nullable CsvRow element)
public boolean addAll(@Nullable Collection<? extends CsvRow> collection)
addAll
in interface Collection<CsvRow>
addAll
in interface List<CsvRow>
addAll
in class ProxiedCollection<CsvRow>
public boolean addAll(int index, @Nullable Collection<? extends CsvRow> collection)
public boolean addAllList(Collection<? extends List<String>> collection)
collection
to this CSV object.
The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (This implies, that the behavior of this call is undefined if the specified collection is this CSV object, and this CSV object is non-empty.)
collection
- the collection containing CSV rows to be addedtrue
if this CSV object changed as a result of the call, else
false
UnsupportedOperationException
- if this CSV object is unmodifiable@NonNull public CsvRow get(int index)
public List<String> getHeaders()
@NonNull public CsvRow remove(int index)
public String toString()
toString
in class ProxiedCollection<CsvRow>
public String toString(char separator, char escaper)
separator
and escaper
.
This is a short-hand method for
StringConverters.encodeCsv(Collection, char, char)
.
separator
- the CSV separatorescaper
- the CSV value escaperseparator
and
escaper
public Csv unmodifiable()
public char getSeparator()
public char getEscaper()
public boolean isModifiable()
isModifiable
in class ProxiedCollection<CsvRow>
true
if this instance is modifiable, else false
Copyright © 2025. All rights reserved.