T
- public class HeaderColumnNameMappingStrategy<T> extends Object implements MappingStrategy<T>
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
HeaderColumnNameMappingStrategy()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
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.
|
protected String[] header
protected Map<String,PropertyDescriptor> descriptorMap
protected boolean annotationDriven
protected boolean determinedIfAnnotationDriven
public HeaderColumnNameMappingStrategy()
public void captureHeader(CSVReader reader) throws IOException
captureHeader
in interface MappingStrategy<T>
reader
- the CSVReader to use for header parsingIOException
- - 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 namepublic PropertyDescriptor findDescriptor(int col) throws IntrospectionException
findDescriptor
in interface MappingStrategy<T>
col
- the column to find the description forIntrospectionException
- - thrown on error retrieving the property description.public BeanField findField(int col)
findField
in interface MappingStrategy<T>
col
- the column to find the field forpublic 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 againstprotected Map<String,PropertyDescriptor> loadDescriptorMap() throws IntrospectionException
IntrospectionException
- - thrown on error getting information about the bean.protected Map<String,BeanField> loadFieldMap()
public T createBean() throws ReflectiveOperationException
createBean
in interface MappingStrategy<T>
ReflectiveOperationException
- - 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>
Copyright © 2019 Liquibase.org. All rights reserved.