T
- The type of the bean being populatedI
- The index of the MultiValuedMap
in usepublic abstract class BeanFieldJoin<T,I> extends BeanFieldSingleValue<T,I>
capture, writeFormat
converter, errorLocale, field, fieldAccess, required, type
Constructor and Description |
---|
BeanFieldJoin(Class<?> type,
Field field,
boolean required,
Locale errorLocale,
CsvConverter converter,
Class<? extends org.apache.commons.collections4.MultiValuedMap> mapType,
String capture,
String format)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
protected void |
assignValueToField(Object bean,
Object obj,
String header)
Assigns the value given to the proper field of the bean given.
|
Object[] |
indexAndSplitMultivaluedField(Object value,
I index)
Given the value of a bean field and an index into that value, determine
what values need to be written.
|
protected boolean |
isFieldEmptyForWrite(Object value)
Checks that
value is not null and not empty. |
protected abstract Object |
putNewValue(org.apache.commons.collections4.MultiValuedMap<I,Object> map,
String index,
Object newValue)
Puts the value given in
newValue into map using
index . |
convert, convertToWrite
getErrorLocale, getField, getFieldValue, getType, isRequired, setErrorLocale, setField, setFieldValue, setRequired, setType, write
public BeanFieldJoin(Class<?> type, Field field, boolean required, Locale errorLocale, CsvConverter converter, Class<? extends org.apache.commons.collections4.MultiValuedMap> mapType, String capture, String format)
type
- The type of the class in which this field is found. This is
the type as instantiated by opencsv, and not necessarily the
type in which the field is declared in the case of
inheritance.field
- The bean field this object representsrequired
- Whether or not a value is always required for this fielderrorLocale
- The locale to use for error messagesconverter
- The converter to be used for performing the data
conversion on reading or writingmapType
- The type of the
MultiValuedMap
that should be
instantiated for the bean field being populatedcapture
- See CsvBindAndJoinByName.capture()
format
- The format string used for packaging values to be written.
If null
or empty, it is ignored.protected abstract Object putNewValue(org.apache.commons.collections4.MultiValuedMap<I,Object> map, String index, Object newValue)
newValue
into map
using
index
.
This allows derived classes to do something special before assigning the
value, such as converting the index to a different type.map
- The map to which to assign the new value. Never null.index
- The index under which the new value should be placed in the
map. Never null.newValue
- The new value to be put in the mapprotected void assignValueToField(Object bean, Object obj, String header) throws CsvDataTypeMismatchException
assignValueToField
in class AbstractBeanField<T,I>
bean
- The bean in which the field is locatedobj
- The data to be assigned to this field of the destination beanheader
- The header from the CSV file under which this value was found.CsvDataTypeMismatchException
- If the data to be assigned cannot
be converted to the type of the destination fieldpublic Object[] indexAndSplitMultivaluedField(Object value, I index) throws CsvDataTypeMismatchException
BeanField
indexAndSplitMultivaluedField
in interface BeanField<T,I>
indexAndSplitMultivaluedField
in class AbstractBeanField<T,I>
value
- The value of the bean field that should be writtenindex
- An index into value
that determines which of the
many possible values are currently being written. For header-based
mapping strategies, this will be the header name, and for column
position mapping strategies, it will be the zero-based column position.MultiValuedMap
addressed by
this bean field answering to the key given in index
CsvDataTypeMismatchException
- If value
is not of the type
expected by the implementing classprotected boolean isFieldEmptyForWrite(Object value)
value
is not null and not empty.isFieldEmptyForWrite
in class AbstractBeanField<T,I>
value
- The value of a field out of a bean that is being written to
a CSV file. Can be null
.value
to be
empty for the purposes of its conversionCopyright © 2005–2023. All rights reserved.