|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectliquibase.util.csv.opencsv.bean.HeaderColumnNameMappingStrategy<T>
T - public class HeaderColumnNameMappingStrategy<T>
Maps data to objects using the column names in the first row of the csv file as reference. This way the column order does not matter.
| Field Summary | |
|---|---|
protected boolean |
annotationDriven
|
protected Map<String,PropertyDescriptor> |
descriptorMap
|
protected boolean |
determinedIfAnnotationDriven
|
protected Map<String,BeanField> |
fieldMap
|
protected String[] |
header
|
protected Map<String,Integer> |
indexLookup
|
protected Class<T> |
type
|
| Constructor Summary | |
|---|---|
HeaderColumnNameMappingStrategy()
Default constructor. |
|
| Method Summary | |
|---|---|
void |
captureHeader(CSVReader reader)
Retrieves the header from the CSVReader. |
T |
createBean()
Creates an object to be mapped. |
protected void |
createIndexLookup(String[] values)
Creates an index map of column names to column position. |
PropertyDescriptor |
findDescriptor(int col)
Gets the property descriptor for a given column position. |
protected PropertyDescriptor |
findDescriptor(String name)
Find the property descriptor for a given column. |
BeanField |
findField(int col)
Gets the field for a given column position. |
protected BeanField |
findField(String name)
Find the field for a given column. |
Integer |
getColumnIndex(String name)
Gets the column index that corresponds to a specific colum name. |
String |
getColumnName(int col)
Get the column name for a given column position. |
Class<T> |
getType()
get the class type that the Strategy is mapping. |
boolean |
isAnnotationDriven()
Determines whether the mapping strategy is driven by CsvBind annotations. |
protected Map<String,PropertyDescriptor> |
loadDescriptorMap()
builds a map of property descriptors for the Bean. |
protected Map<String,BeanField> |
loadFieldMap()
Builds a map of fields (and whether they're mandatory) for the Bean. |
protected boolean |
matches(String name,
PropertyDescriptor desc)
Determines if the name of a property descriptor matches the column name. |
protected void |
resetIndexMap()
Resets index map of column names to column position. |
void |
setType(Class<T> type)
Sets the class type that is being mapped. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected String[] header
protected Map<String,Integer> indexLookup
protected Map<String,PropertyDescriptor> descriptorMap
protected Map<String,BeanField> fieldMap
protected Class<T> type
protected boolean annotationDriven
protected boolean determinedIfAnnotationDriven
| Constructor Detail |
|---|
public HeaderColumnNameMappingStrategy()
| Method Detail |
|---|
public void captureHeader(CSVReader reader)
throws IOException
captureHeader in interface MappingStrategy<T>reader - the CSVReader to use for header parsing
IOException - - thrown on error reading from the CSVReader.protected void createIndexLookup(String[] values)
values - - array of header values.protected void resetIndexMap()
public Integer getColumnIndex(String name)
getColumnIndex in interface MappingStrategy<T>name - the column name
public PropertyDescriptor findDescriptor(int col)
throws IntrospectionException
findDescriptor in interface MappingStrategy<T>col - the column to find the description for
IntrospectionException - - thrown on error retrieving the property description.public BeanField findField(int col)
findField in interface MappingStrategy<T>col - the column to find the field for
public String getColumnName(int col)
col - - column position.
protected PropertyDescriptor findDescriptor(String name)
throws IntrospectionException
name - - column name to look up.
IntrospectionException - - thrown on error loading the property descriptors.protected BeanField findField(String name)
name - - the column name to look up.
protected boolean matches(String name,
PropertyDescriptor desc)
name - - name of the column.desc - - property descriptor to check against
protected Map<String,PropertyDescriptor> loadDescriptorMap()
throws IntrospectionException
IntrospectionException - - thrown on error getting information about the bean.protected Map<String,BeanField> loadFieldMap()
public T createBean()
throws InstantiationException,
IllegalAccessException
createBean in interface MappingStrategy<T>InstantiationException - - thrown on error creating object.
IllegalAccessException - - thrown on error creating object.public Class<T> getType()
public void setType(Class<T> type)
type - Class type.public boolean isAnnotationDriven()
CsvBind annotations.
isAnnotationDriven in interface MappingStrategy<T>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||