| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj)
Checks if this CSV file equals another.
|
String |
field(int index)
Gets the specified field.
|
int |
fieldCount()
Gets the number of fields.
|
ImmutableList<String> |
fields()
Gets all fields in the row.
|
Optional<String> |
findField(Pattern headerPattern)
Gets a single field value from the row by header pattern.
|
Optional<String> |
findField(String header)
Gets a single field value from the row by header.
|
Optional<String> |
findValue(Pattern headerPattern)
Gets a single value from the row by header pattern.
|
Optional<String> |
findValue(String header)
Gets a single value from the row by header.
|
String |
getField(Pattern headerPattern)
Gets a single field value from the row by header pattern.
|
<T> T |
getField(Pattern headerPattern,
Function<String,T> postProcessor)
Gets a single field value from the row by header pattern, post processing the result.
|
String |
getField(String header)
Gets a single field value from the row by header.
|
<T> T |
getField(String header,
Function<String,T> postProcessor)
Gets a single field value from the row by header, post processing the result.
|
String |
getValue(Pattern headerPattern)
Gets a single field value from the row by header pattern.
|
<T> T |
getValue(Pattern headerPattern,
Function<String,T> postProcessor)
Gets a single field value from the row by header pattern, post processing the result.
|
String |
getValue(String header)
Gets a single field value from the row by header.
|
<T> T |
getValue(String header,
Function<String,T> postProcessor)
Gets a single field value from the row by header, post processing the result.
|
int |
hashCode()
Returns a suitable hash code for the CSV file.
|
ImmutableList<String> |
headers()
Gets the header row.
|
int |
lineNumber()
Gets the line number in the source file.
|
CsvRow |
subRow(int startInclusive)
Obtains a sub-row, containing a selection of fields by index.
|
CsvRow |
subRow(int startInclusive,
int endExclusive)
Obtains a sub-row, containing a selection of fields by index.
|
String |
toString()
Returns a string describing the CSV file.
|
public ImmutableList<String> headers()
If there is no header row, an empty list is returned.
public int lineNumber()
public ImmutableList<String> fields()
public int fieldCount()
This will never be less than the number of headers.
public String field(int index)
index - the field indexIndexOutOfBoundsException - if the field index is invalidpublic String getField(String header)
This returns the value of the first column where the header matches the specified header. Matching is case insensitive.
header - the column headerIllegalArgumentException - if the header is not foundpublic <T> T getField(String header, Function<String,T> postProcessor)
This returns the value of the first column where the header matches the specified header. Matching is case insensitive.
The value is post processed via the specified function.
T - the post process result typeheader - the column headerpostProcessor - the post processorIllegalArgumentException - if the header is not foundpublic Optional<String> findField(String header)
This returns the value of the first column where the header matches the specified header. Matching is case insensitive.
If the value needs post processing, use Optional.map(Function).
header - the column headerpublic String getField(Pattern headerPattern)
This returns the value of the first column where the header matches the specified header pattern.
headerPattern - the header pattern to matchIllegalArgumentException - if the header is not foundpublic <T> T getField(Pattern headerPattern, Function<String,T> postProcessor)
This returns the value of the first column where the header matches the specified header pattern.
The value is post processed via the specified function.
T - the post process result typeheaderPattern - the header pattern to matchpostProcessor - the post processorIllegalArgumentException - if the header is not foundpublic Optional<String> findField(Pattern headerPattern)
This returns the value of the first column where the header matches the specified header pattern.
If the value needs post processing, use Optional.map(Function).
headerPattern - the header pattern to matchpublic String getValue(String header)
This returns the value of the first column where the header matches the specified header. If the header is not found or the value found is an empty string, then an IllegalArgumentException is thrown.
header - the column headerIllegalArgumentException - if the header is not found or if the value in the field is empty.public <T> T getValue(String header, Function<String,T> postProcessor)
This returns the value of the first column where the header matches the specified header. If the header is not found or the value found is an empty string, then an IllegalArgumentException is thrown.
The value is post processed via the specified function.
T - the post process result typeheader - the column headerpostProcessor - the post processorIllegalArgumentException - if the header is not found or if the value in the field is empty.public Optional<String> findValue(String header)
This returns the value of the first column where the header matches the specified header pattern. If the value is an empty string, then an empty optional is returned.
If the value needs post processing, use Optional.map(Function).
header - the column headerpublic String getValue(Pattern headerPattern)
This returns the value of the first column where the header matches the specified header pattern. If the header is not found or the value found is an empty string, then an IllegalArgumentException is thrown.
headerPattern - the header pattern to matchIllegalArgumentException - if the header is not found or if the value in the field is empty.public <T> T getValue(Pattern headerPattern, Function<String,T> postProcessor)
This returns the value of the first column where the header matches the specified header pattern. If the header is not found or the value found is an empty string, then an IllegalArgumentException is thrown.
The value is post processed via the specified function.
T - the post process result typeheaderPattern - the header pattern to matchpostProcessor - the post processorIllegalArgumentException - if the header is not found or if the value in the field is empty.public Optional<String> findValue(Pattern headerPattern)
This returns the value of the first column where the header matches the specified header pattern. If the value is an empty string, then an empty optional is returned.
If the value needs post processing, use Optional.map(Function).
headerPattern - the header pattern to matchpublic CsvRow subRow(int startInclusive)
All fields after the specified index are included.
startInclusive - the start index, zero-based, inclusivepublic CsvRow subRow(int startInclusive, int endExclusive)
startInclusive - the start index, zero-based, inclusiveendExclusive - the end index, zero-based, exclusivepublic boolean equals(Object obj)
The comparison checks the content.
public int hashCode()
Copyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.