Package com.opencsv.bean
Class PositionToBeanField<T>
- Type Parameters:
T
- Type of the bean being converted
- All Implemented Interfaces:
ComplexFieldMapEntry<String,
,Integer, T> Iterable<FieldMapByPositionEntry<T>>
public class PositionToBeanField<T>
extends AbstractFieldMapEntry<String,Integer,T>
implements Iterable<FieldMapByPositionEntry<T>>
Maps any column position matching a range definition to a
BeanField
.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate class
This iterator is designed to iterate over every element of all of the ranges specified in the containing class. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final String
This is the string used to initialize this set of ranges.A list of ranges of column indices that should be mapped to the associated bean.Fields inherited from class com.opencsv.bean.AbstractFieldMapEntry
errorLocale, field
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
attenuateRanges
(int maxIndex) If there are ranges in the list of ranges encompassed by this mapping that stretch beyond the maximum index given, they are shortened to be no longer than the maximum index.boolean
Determines whether or not the given key is contained in this entry.Returns the information used to initialize this entry.iterator()
Methods inherited from class com.opencsv.bean.AbstractFieldMapEntry
getBeanField, setErrorLocale
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
initializer
This is the string used to initialize this set of ranges. This is necessary because the ranges may be attenuated later byattenuateRanges(int)
, rendering a reconstruction of the original initialization information impossible. -
ranges
A list of ranges of column indices that should be mapped to the associated bean.
-
-
Constructor Details
-
PositionToBeanField
public PositionToBeanField(String rangeDefinition, int maxIndex, BeanField<T, Integer> field, Locale errorLocale) Initializes this mapping with a list of ranges and the associatedBeanField
.- Parameters:
rangeDefinition
- A definition of ranges as documented inCsvBindAndJoinByPosition.position()
maxIndex
- The maximum index allowed for a range. Ranges will be adjusted as documented inattenuateRanges(int)
.field
- TheBeanField
this mapping maps toerrorLocale
- The locale for error messages- Throws:
CsvBadConverterException
- IfrangeDefinition
cannot be parsed
-
-
Method Details
-
attenuateRanges
public void attenuateRanges(int maxIndex) If there are ranges in the list of ranges encompassed by this mapping that stretch beyond the maximum index given, they are shortened to be no longer than the maximum index. Ranges that lie completely beyond the maximum index are shortened to a one-element range consisting of the range's lower boundary. No ranges are under any circumstances removed, as this might compromise checks for required fields.- Parameters:
maxIndex
- The new maximum for ranges
-
contains
Description copied from interface:ComplexFieldMapEntry
Determines whether or not the given key is contained in this entry.- Specified by:
contains
in interfaceComplexFieldMapEntry<String,
Integer, T> - Parameters:
key
- The key to be located- Returns:
- Whether
key
is represented by this entry
-
getInitializer
Description copied from interface:ComplexFieldMapEntry
Returns the information used to initialize this entry. This information is not guaranteed to be exactly the same as the original value, but is functionally equivalent.- Specified by:
getInitializer
in interfaceComplexFieldMapEntry<String,
Integer, T> - Returns:
- The original information used to initialize this mapping entry
-
iterator
-