liquibase.util.csv.opencsv.bean
Class ColumnPositionMappingStrategy<T>

java.lang.Object
  extended by liquibase.util.csv.opencsv.bean.HeaderColumnNameMappingStrategy<T>
      extended by liquibase.util.csv.opencsv.bean.ColumnPositionMappingStrategy<T>
Type Parameters:
T - - Type of object that is being processed.
All Implemented Interfaces:
MappingStrategy<T>

public class ColumnPositionMappingStrategy<T>
extends HeaderColumnNameMappingStrategy<T>

Allows for the mapping of columns with their positions. Using this strategy requires all the columns to be present in the csv file and for them to be in a particular order. Also this strategy requires that the file does NOT have an header. That said the main use of this strategy is files that do not have headers.


Field Summary
 
Fields inherited from class liquibase.util.csv.opencsv.bean.HeaderColumnNameMappingStrategy
annotationDriven, descriptorMap, determinedIfAnnotationDriven, fieldMap, header, indexLookup, type
 
Constructor Summary
ColumnPositionMappingStrategy()
          Default Constructor.
 
Method Summary
 void captureHeader(CSVReader reader)
          Captures the header from the reader - required by the MappingStrategy interface and is a do nothing method for the ColumnPositionMappingStrategy.
 Integer getColumnIndex(String name)
          gets the column position for a given column name.
 String[] getColumnMapping()
          Retrieves the column mappings.
 String getColumnName(int col)
          gets a column name.
 void setColumnMapping(String... columnMapping)
          Setter for the ColumnMappings.
 
Methods inherited from class liquibase.util.csv.opencsv.bean.HeaderColumnNameMappingStrategy
createBean, createIndexLookup, findDescriptor, findDescriptor, findField, findField, getType, isAnnotationDriven, loadDescriptorMap, loadFieldMap, matches, resetIndexMap, setType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColumnPositionMappingStrategy

public ColumnPositionMappingStrategy()
Default Constructor.

Method Detail

captureHeader

public void captureHeader(CSVReader reader)
                   throws IOException
Captures the header from the reader - required by the MappingStrategy interface and is a do nothing method for the ColumnPositionMappingStrategy.

Specified by:
captureHeader in interface MappingStrategy<T>
Overrides:
captureHeader in class HeaderColumnNameMappingStrategy<T>
Parameters:
reader - - CSVReader.
Throws:
IOException - - would be thrown by the CSVReader if it was used :)

getColumnIndex

public Integer getColumnIndex(String name)
gets the column position for a given column name.

Specified by:
getColumnIndex in interface MappingStrategy<T>
Overrides:
getColumnIndex in class HeaderColumnNameMappingStrategy<T>
Parameters:
name - the column name
Returns:
- column position or null if the name does not map.

getColumnName

public String getColumnName(int col)
gets a column name.

Overrides:
getColumnName in class HeaderColumnNameMappingStrategy<T>
Parameters:
col - - position of the column.
Returns:
- column name or null if col > number of mappings.

getColumnMapping

public String[] getColumnMapping()
Retrieves the column mappings.

Returns:
- String array with the column mappings.

setColumnMapping

public void setColumnMapping(String... columnMapping)
Setter for the ColumnMappings.

Parameters:
columnMapping - - column names to be mapped.


Copyright © 2016 Liquibase.org. All rights reserved.