T
- Type of the bean being convertedpublic class FieldMapByPosition<T> extends AbstractFieldMap<String,Integer,PositionToBeanField<T>,T> implements Iterable<FieldMapByPositionEntry<T>>
complexMapList, errorLocale, simpleMap
Constructor and Description |
---|
FieldMapByPosition(Locale errorLocale)
Initializes this
FieldMap . |
Modifier and Type | Method and Description |
---|---|
String[] |
generateHeader(T bean)
This method generates a header that can be used for writing beans of the
type provided back to a file.
|
Iterator<FieldMapByPositionEntry<T>> |
iterator() |
void |
putComplex(String rangeDefinition,
BeanField<T,Integer> field)
Adds a
BeanField to this map indexed by the data in
initializer . |
void |
setColumnOrderOnWrite(Comparator<Integer> writeOrder)
Sets the
Comparator to be used to sort columns when
writing beans to a CSV file. |
void |
setMaxIndex(int maxIndex)
Sets the maximum index for all ranges specified in the entire field map.
|
get, put, setErrorLocale, values
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public String[] generateHeader(T bean) throws CsvRequiredFieldEmptyException
Comparator
passed in to
setColumnOrderOnWrite(Comparator)
. Otherwise, it is ascending
according to position.generateHeader
in interface FieldMap<String,Integer,PositionToBeanField<T>,T>
bean
- One perfect, shining example of how the bean to be written
should look. The most crucial thing is, for fields that result from
joining multiple fields on reading and thus need to be split on
writing, the MultiValuedMap
in
question must have the complete structure of the header to be
generated, even if some values are empty.CsvRequiredFieldEmptyException
- If a required header is missing
while attempting to write. Since every other header is hard-wired
through the bean fields and their associated annotations, this can only
happen with multi-valued fields.public void putComplex(String rangeDefinition, BeanField<T,Integer> field)
FieldMap
BeanField
to this map indexed by the data in
initializer
.
This is what makes this map special: It allows one to define
characteristics of a method to match multiple keys.putComplex
in interface FieldMap<String,Integer,PositionToBeanField<T>,T>
rangeDefinition
- A string describing the column positions to be
matched.field
- The BeanField
that is to be returned on a later
matchCsvBindAndJoinByPosition.position()
public void setMaxIndex(int maxIndex)
maxIndex
, these are preserved, though ranges
are shortened to a single value (the lower boundry).maxIndex
- The maximum index in the data being importedpublic Iterator<FieldMapByPositionEntry<T>> iterator()
iterator
in interface Iterable<FieldMapByPositionEntry<T>>
public void setColumnOrderOnWrite(Comparator<Integer> writeOrder)
Comparator
to be used to sort columns when
writing beans to a CSV file.writeOrder
- The Comparator
to use. May be
null
, in which case the natural ordering is used.Copyright © 2005–2023. All rights reserved.