org.apache.commons.collections4.BidiMap will not do the
trick, because header names (or null in place of a header name) may appear
more than once.
| Modifier and Type | Field and Description |
|---|---|
| private MultiValuedMap | headerToPosition
The uni-directional map from header name to (possibly multiple) column positions. |
| private String[] | positionToHeader
The uni-directional map from column position to header name. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public int | Returns: The maximum index that is mapped and will return a header name (or null if specifically mapped that way). If there are no columns in the mapping, returns -1.Finds and returns the highest index in this mapping. |
| public int[] | |
| public String | Returns: The header name mapped by positioniThe column position for which the header name is to be retrieved i)Retrieves the header associated with the given column position. |
| public String[] | |
| public int | |
| public void | initializeHeaderIndex(String[]
A list of header names in the order in which they are
expected in the CSV input header)Initializes the index with a list of header names in proper encounter order. |
| public boolean | |
| public void |
| headerToPosition | back to summary |
|---|---|
| private MultiValuedMap<String, Integer> headerToPosition The uni-directional map from header name to (possibly multiple) column positions. | |
| positionToHeader | back to summary |
|---|---|
| private String[] positionToHeader The uni-directional map from column position to header name. | |
| HeaderIndex | back to summary |
|---|---|
| public HeaderIndex() Useless but explicit nullary constructor to make the style checker happy. | |
| clear | back to summary |
|---|---|
| public void clear() Empties the entire mapping. | |
| findMaxIndex | back to summary |
|---|---|
| public int findMaxIndex() Finds and returns the highest index in this mapping.
| |
| getByName | back to summary |
|---|---|
| public int[] getByName(String headerName) Retrieves the column position(s) associated with the given header name.
| |
| getByPosition | back to summary |
|---|---|
| public String getByPosition(int i) Retrieves the header associated with the given column position.
| |
| getHeaderIndex | back to summary |
|---|---|
public String[] getHeaderIndex()
| |
| getHeaderIndexLength | back to summary |
|---|---|
public int getHeaderIndexLength()
| |
| initializeHeaderIndex | back to summary |
|---|---|
| public void initializeHeaderIndex(String[] header) Initializes the index with a list of header names in proper encounter
order.
"Proper encounter order" means the order in which they are expected to be
found in the input CSV. Header names may be listed more than once if the
destination field is annotated with
| |
| isEmpty | back to summary |
|---|---|
public boolean isEmpty()
| |
| put | back to summary |
|---|---|
| public void put(int k, String v) Adds a new mapping between a column position and a header. The header may already be present, in which case the column position is added to the list of column positions mapped to the header.
| |