Top Description Fields Constructors Methods
com.opencsv.bean

public Class HeaderColumnNameMappingStrategy<T>

extends HeaderNameBaseMappingStrategy<T>
Class Inheritance
Known Direct Subclasses
com.opencsv.bean.FuzzyMappingStrategy
Type Parameters
<T>
Type of the bean to be returned
Imports
org.apache.commons.collections4.ListValuedMap, org.apache.commons.lang3.StringUtils, java.lang.annotation.Annotation, java.lang.reflect.Field, java.util.*

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

Inherited from com.opencsv.bean.HeaderNameBaseMappingStrategy:
fieldMapforceCorrectRecordLengthwriteOrder

Constructor Summary

AccessConstructor and Description
public
HeaderColumnNameMappingStrategy()

Default constructor.

public
HeaderColumnNameMappingStrategy(boolean
If set, every record will be shortened or lengthened to match the number of headers
forceCorrectRecordLength
)

Constructor to allow setting options for header name mapping.

Method Summary

Modifier and TypeMethod and Description
protected Set<Class<? extends Annotation>>
getBindingAnnotations()

Overrides com.opencsv.bean.AbstractMappingStrategy.getBindingAnnotations.

Returns a set of the annotations that are used for binding in this mapping strategy.

protected void
loadAnnotatedFieldMap(ListValuedMap<Class<?>, Field> fields)

Overrides com.opencsv.bean.AbstractMappingStrategy.loadAnnotatedFieldMap.

Creates a map of annotated fields in the bean to be processed.

private void
registerBinding(CsvBindByName
The annotation attached to the bean field
annotation
,
Class<?>
The class/type in which the field resides
localType
,
Field
The bean field
localField
)

Register a binding between a bean field and a simple converter.

private void
registerCustomBinding(CsvCustomBindByName
The annotation attached to the bean field
annotation
,
Class<?>
The class/type in which the field resides
localType
,
Field
The bean field
localField
)

Register a binding between a bean field and a custom converter.

private void
registerJoinBinding(CsvBindAndJoinByName
The annotation attached to the bean field
annotation
,
Class<?>
The class/type in which the field resides
localType
,
Field
The bean field
localField
)

Register a binding between a bean field and a multi-valued converter that joins values from multiple columns.

private void
registerSplitBinding(CsvBindAndSplitByName
The annotation attached to the bean field
annotation
,
Class<?>
The class/type in which the field resides
localType
,
Field
The bean field
localField
)

Register a binding between a bean field and a collection converter that splits input into multiple values.

Inherited from com.opencsv.bean.HeaderNameBaseMappingStrategy:
captureHeaderchooseMultivaluedFieldIndexFromHeaderIndexfindFieldfindHeadergetFieldMapinitializeFieldMaploadUnadornedFieldMapsetColumnOrderOnWriteverifyLineLength

Constructor Detail

HeaderColumnNameMappingStrategyback to summary
public HeaderColumnNameMappingStrategy()

Default constructor. Considered stable.

See Also
HeaderColumnNameMappingStrategyBuilder
HeaderColumnNameMappingStrategyback to summary
public HeaderColumnNameMappingStrategy(boolean forceCorrectRecordLength)

Constructor to allow setting options for header name mapping. Not considered stable. As new options are introduced for the mapping strategy, they will be introduced here. You are encouraged to use HeaderColumnNameMappingStrategyBuilder.

Parameters
forceCorrectRecordLength:boolean

If set, every record will be shortened or lengthened to match the number of headers

See Also
HeaderColumnNameMappingStrategyBuilder

Method Detail

getBindingAnnotationsback to summary
protected Set<Class<? extends Annotation>> getBindingAnnotations()

Overrides com.opencsv.bean.AbstractMappingStrategy.getBindingAnnotations.

Returns a set of the annotations that are used for binding in this mapping strategy.

In this mapping strategy, those are currently:

Annotations
@Override
loadAnnotatedFieldMapback to summary
protected void loadAnnotatedFieldMap(ListValuedMap<Class<?>, Field> fields)

Overrides com.opencsv.bean.AbstractMappingStrategy.loadAnnotatedFieldMap.

Creates a map of annotated fields in the bean to be processed.

This method is called by loadFieldMap() when at least one relevant annotation is found on a member variable.

Annotations
@Override
registerBindingback to summary
private void registerBinding(CsvBindByName annotation, Class<?> localType, Field localField)

Register a binding between a bean field and a simple converter.

Parameters
annotation:CsvBindByName

The annotation attached to the bean field

localType:Class<?>

The class/type in which the field resides

localField:Field

The bean field

registerCustomBindingback to summary
private void registerCustomBinding(CsvCustomBindByName annotation, Class<?> localType, Field localField)

Register a binding between a bean field and a custom converter.

Parameters
annotation:CsvCustomBindByName

The annotation attached to the bean field

localType:Class<?>

The class/type in which the field resides

localField:Field

The bean field

registerJoinBindingback to summary
private void registerJoinBinding(CsvBindAndJoinByName annotation, Class<?> localType, Field localField)

Register a binding between a bean field and a multi-valued converter that joins values from multiple columns.

Parameters
annotation:CsvBindAndJoinByName

The annotation attached to the bean field

localType:Class<?>

The class/type in which the field resides

localField:Field

The bean field

registerSplitBindingback to summary
private void registerSplitBinding(CsvBindAndSplitByName annotation, Class<?> localType, Field localField)

Register a binding between a bean field and a collection converter that splits input into multiple values.

Parameters
annotation:CsvBindAndSplitByName

The annotation attached to the bean field

localType:Class<?>

The class/type in which the field resides

localField:Field

The bean field