T
- public class HeaderColumnNameMappingStrategy<T> extends Object implements MappingStrategy<T>
Modifier and Type | Field and Description |
---|---|
protected Map<String,PropertyDescriptor> |
descriptorMap |
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.
|
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()
Deprecated.
|
protected Map<String,PropertyDescriptor> |
loadDescriptorMap()
builds a map of property descriptors 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)
Deprecated.
|
protected String[] header
protected Map<String,PropertyDescriptor> descriptorMap
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 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 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.public T createBean() throws InstantiationException, IllegalAccessException
createBean
in interface MappingStrategy<T>
InstantiationException
- - thrown on error creating object.IllegalAccessException
- - thrown on error creating object.@Deprecated public Class<T> getType()
@Deprecated public void setType(Class<T> type)
type
- Class type.Copyright © 2015. All rights reserved.