Package com.opencsv.bean
Class AbstractFieldMap<I,K extends java.lang.Comparable<K>,C extends ComplexFieldMapEntry<I,K,T>,T>
- java.lang.Object
-
- com.opencsv.bean.AbstractFieldMap<I,K,C,T>
-
- Type Parameters:
I
- The initializer type used to build the many-to-one mappingK
- Type of the field identifier (key)C
- Type of the ComplexFieldMapEntry usedT
- Type of the bean being converted
- All Implemented Interfaces:
FieldMap<I,K,C,T>
- Direct Known Subclasses:
FieldMapByName
,FieldMapByPosition
public abstract class AbstractFieldMap<I,K extends java.lang.Comparable<K>,C extends ComplexFieldMapEntry<I,K,T>,T> extends java.lang.Object implements FieldMap<I,K,C,T>
A base class to collect all generalized components of aFieldMap
. May be used by all as a base class for their own implementations ofFieldMap
.- Since:
- 4.2
- Author:
- Andrew Rucker Jones
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<C>
complexMapList
A list of entries representing all complex, that is many-to-one, mappings represented in thisFieldMap
.protected java.util.Locale
errorLocale
The locale for error messages.protected java.util.SortedMap<K,BeanField<T,K>>
simpleMap
A map for all simple, that is one-to-one, mappings represented in thisFieldMap
.
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractFieldMap(java.util.Locale errorLocale)
Initializes thisFieldMap
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BeanField<T,K>
get(K key)
Gets theBeanField
associated with this key.BeanField<T,K>
put(K key, BeanField<T,K> value)
Associates the givenBeanField
with the givenkey
.void
setErrorLocale(java.util.Locale errorLocale)
Sets the locale to be used for error messages.java.util.Collection<BeanField<T,K>>
values()
Provides all values currently in the map.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.opencsv.bean.FieldMap
generateHeader, putComplex
-
-
-
-
Field Detail
-
errorLocale
protected java.util.Locale errorLocale
The locale for error messages.
-
simpleMap
protected final java.util.SortedMap<K extends java.lang.Comparable<K>,BeanField<T,K extends java.lang.Comparable<K>>> simpleMap
A map for all simple, that is one-to-one, mappings represented in thisFieldMap
.
-
-
Constructor Detail
-
AbstractFieldMap
protected AbstractFieldMap(java.util.Locale errorLocale)
Initializes thisFieldMap
.- Parameters:
errorLocale
- The locale to be used for error messages
-
-
Method Detail
-
get
public BeanField<T,K> get(K key)
Description copied from interface:FieldMap
Gets theBeanField
associated with this key. If a key could possibly match both a regular, simple key (one added withFieldMap.put(Comparable, BeanField)
), and a complex key (one added withFieldMap.putComplex(java.lang.Object, com.opencsv.bean.BeanField)
), the simple key is always matched. If a key could match more than one complex key, the return value is undefined.
-
put
public BeanField<T,K> put(K key, BeanField<T,K> value)
Description copied from interface:FieldMap
Associates the givenBeanField
with the givenkey
.- Specified by:
put
in interfaceFieldMap<I,K extends java.lang.Comparable<K>,C extends ComplexFieldMapEntry<I,K,T>,T>
- Parameters:
key
- The key under which to index the providedBeanField
value
- TheBeanField
to be indexed- Returns:
- If there was a value previously associated with this key, it is returned
-
values
public java.util.Collection<BeanField<T,K>> values()
Description copied from interface:FieldMap
Provides all values currently in the map.
-
setErrorLocale
public void setErrorLocale(java.util.Locale errorLocale)
Description copied from interface:FieldMap
Sets the locale to be used for error messages.
-
-