liquibase.util.csv.opencsv.bean
Interface MappingStrategy<T>

Type Parameters:
T - type of object you are converting the data to.
All Known Implementing Classes:
ColumnPositionMappingStrategy, HeaderColumnNameMappingStrategy, HeaderColumnNameTranslateMappingStrategy

public interface MappingStrategy<T>

The interface for the classes that handle translating between the columns in the csv file to an actual object.


Method Summary
 void captureHeader(CSVReader reader)
          Implementation of this method can grab the header line before parsing begins to use to map columns to bean properties.
 T createBean()
          Implementation will return a bean of the type of object you are mapping.
 PropertyDescriptor findDescriptor(int col)
          Implementation will have to return a property descriptor from a bean based on the current column.
 BeanField findField(int col)
          Implementation will have to return - based on the current column - a BeanField containing the Field and a boolean representing whether the field is required (mandatory) or not.
 Integer getColumnIndex(String name)
          Gets the column index that corresponds to a specific colum name.
 boolean isAnnotationDriven()
          Determines whether the mapping strategy is driven by CsvBind annotations.
 

Method Detail

findDescriptor

PropertyDescriptor findDescriptor(int col)
                                  throws IntrospectionException
Implementation will have to return a property descriptor from a bean based on the current column.

Parameters:
col - the column to find the description for
Returns:
the related PropertyDescriptor
Throws:
IntrospectionException - - thrown on error loading the property descriptors.

findField

BeanField findField(int col)
Implementation will have to return - based on the current column - a BeanField containing the Field and a boolean representing whether the field is required (mandatory) or not.

Parameters:
col - the column to find the field for
Returns:
BeanField containing Field and whether it is required

createBean

T createBean()
             throws InstantiationException,
                    IllegalAccessException
Implementation will return a bean of the type of object you are mapping.

Returns:
A new instance of the class being mapped.
Throws:
InstantiationException - - thrown on error creating object.
IllegalAccessException - - thrown on error creating object.

captureHeader

void captureHeader(CSVReader reader)
                   throws IOException
Implementation of this method can grab the header line before parsing begins to use to map columns to bean properties.

Parameters:
reader - the CSVReader to use for header parsing
Throws:
IOException - if parsing fails

getColumnIndex

Integer getColumnIndex(String name)
Gets the column index that corresponds to a specific colum name. If the CSV file doesn't have a header row, this method will always return null.

Parameters:
name - the column name
Returns:
the column index, or null if the name doesn't exist

isAnnotationDriven

boolean isAnnotationDriven()
Determines whether the mapping strategy is driven by CsvBind annotations.

Returns:
whether the mapping strategy is driven by annotations


Copyright © 2016 Liquibase.org. All rights reserved.