Class FuzzyMappingStrategy<T>
java.lang.Object
com.opencsv.bean.AbstractMappingStrategy<String, String, ComplexFieldMapEntry<String,String,T>, T>
com.opencsv.bean.HeaderNameBaseMappingStrategy<T>
com.opencsv.bean.HeaderColumnNameMappingStrategy<T>
com.opencsv.bean.FuzzyMappingStrategy<T>
- Type Parameters:
T- The type of bean being processed
- All Implemented Interfaces:
MappingStrategy<T>
A mapping strategy that tries to make the best match between header names
and non-annotated member variables.
- Since:
- 5.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classThis is a simple class for grouping header name, member variable name, and the result of fuzzy matching in one sortable place.Nested classes/interfaces inherited from class AbstractMappingStrategy
AbstractMappingStrategy.RecursiveType -
Field Summary
Fields inherited from class HeaderNameBaseMappingStrategy
fieldMap, forceCorrectRecordLength, writeOrderFields inherited from class AbstractMappingStrategy
errorLocale, headerIndex, profile, recursiveTypeTree, type -
Constructor Summary
ConstructorsConstructorDescriptionNullary constructor.FuzzyMappingStrategy(boolean forceCorrectRecordLength) Constructor to allow setting options for header name mapping. -
Method Summary
Modifier and TypeMethodDescriptionvoidcaptureHeader(CSVReader reader) Implementation of this method can grab the header line before parsing begins to use to map columns to bean properties.protected voidloadUnadornedFieldMap(org.apache.commons.collections4.ListValuedMap<Class<?>, Field> fields) This implementation intentionally does nothing in order to allow fuzzy matching in case there are no annotations at all in the class in question.Methods inherited from class HeaderColumnNameMappingStrategy
getBindingAnnotations, loadAnnotatedFieldMapMethods inherited from class HeaderNameBaseMappingStrategy
chooseMultivaluedFieldIndexFromHeaderIndex, findField, findHeader, getFieldMap, initializeFieldMap, setColumnOrderOnWrite, verifyLineLengthMethods inherited from class AbstractMappingStrategy
createBean, determineConverter, filterIgnoredFields, generateHeader, getColumnName, getType, ignoreFields, indexBean, instantiateCustomConverter, isForbiddenClassForRecursion, loadFieldMap, loadRecursiveClasses, partitionFields, populateNewBean, selectAnnotationForProfile, setErrorLocale, setFieldValue, setProfile, setType, transmuteBeanMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface MappingStrategy
isAnnotationDriven
-
Constructor Details
-
FuzzyMappingStrategy
public FuzzyMappingStrategy()Nullary constructor. Considered stable.- See Also:
-
FuzzyMappingStrategy
public FuzzyMappingStrategy(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 useFuzzyMappingStrategyBuilder.- Parameters:
forceCorrectRecordLength- If set, every record will be shortened or lengthened to match the number of headers- See Also:
-
-
Method Details
-
loadUnadornedFieldMap
protected void loadUnadornedFieldMap(org.apache.commons.collections4.ListValuedMap<Class<?>, Field> fields) This implementation intentionally does nothing in order to allow fuzzy matching in case there are no annotations at all in the class in question.- Overrides:
loadUnadornedFieldMapin classHeaderNameBaseMappingStrategy<T>- Parameters:
fields- A list of all non-synthetic fields in the bean to be processed
-
captureHeader
Description copied from interface:MappingStrategyImplementation of this method can grab the header line before parsing begins to use to map columns to bean properties.- Specified by:
captureHeaderin interfaceMappingStrategy<T>- Overrides:
captureHeaderin classHeaderNameBaseMappingStrategy<T>- Parameters:
reader- The CSVReader to use for header parsing- Throws:
IOException- If parsing failsCsvRequiredFieldEmptyException- If a field is required, but the header or column position for the field is not present in the input
-