Top Description Fields Constructors Methods
com.opencsv.bean

public Class HeaderColumnNameTranslateMappingStrategy<T>

extends HeaderNameBaseMappingStrategy<T>
Class Inheritance
Type Parameters
<T>
Class to be mapped.
Imports
java.util.HashMap, .Map

Expands on HeaderColumnNameMappingStrategy by allowing the user to pass in a map of column names to bean names. This way the fields in the bean do not have to match the fields in the CSV file. This is only for when the user passes in the header names programmatically, and not for annotated beans.

Field Summary

Modifier and TypeField and Description
private final Map<String, String>
Inherited from com.opencsv.bean.HeaderNameBaseMappingStrategy:
fieldMapforceCorrectRecordLengthwriteOrder

Constructor Summary

AccessConstructor and Description
public
public
HeaderColumnNameTranslateMappingStrategy(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
public Map<String, String>

Returns:

The column mappings of the strategy.
getColumnMapping
()

Retrieves the column mappings of the strategy.

public String
getColumnName(int col)

Overrides com.opencsv.bean.AbstractMappingStrategy.getColumnName.

Get the column name for a given column position.

public void
setColumnMapping(Map<String, String>
Source column mapping.
columnMapping
)

Sets the column mapping to those passed in.

Inherited from com.opencsv.bean.HeaderNameBaseMappingStrategy:
captureHeaderchooseMultivaluedFieldIndexFromHeaderIndexfindFieldfindHeadergetFieldMapinitializeFieldMaploadUnadornedFieldMapsetColumnOrderOnWriteverifyLineLength

Field Detail

columnMappingback to summary
private final Map<String, String> columnMapping

Constructor Detail

HeaderColumnNameTranslateMappingStrategyback to summary
public HeaderColumnNameTranslateMappingStrategy()

Default constructor. Considered stable.

See Also
HeaderColumnNameTranslateMappingStrategyBuilder
HeaderColumnNameTranslateMappingStrategyback to summary
public HeaderColumnNameTranslateMappingStrategy(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 HeaderColumnNameTranslateMappingStrategyBuilder.

Parameters
forceCorrectRecordLength:boolean

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

See Also
HeaderColumnNameTranslateMappingStrategyBuilder

Method Detail

getColumnMappingback to summary
public Map<String, String> getColumnMapping()

Retrieves the column mappings of the strategy.

Returns:Map<String, String>

The column mappings of the strategy.

getColumnNameback to summary
public String getColumnName(int col)

Overrides com.opencsv.bean.AbstractMappingStrategy.getColumnName.

Doc from com.opencsv.bean.AbstractMappingStrategy.getColumnName.

Get the column name for a given column position.

Annotations
@Override
setColumnMappingback to summary
public void setColumnMapping(Map<String, String> columnMapping)

Sets the column mapping to those passed in.

Parameters
columnMapping:Map<String, String>

Source column mapping.