Package com.opencsv.bean
Class PositionToBeanField<T>
- java.lang.Object
-
- com.opencsv.bean.AbstractFieldMapEntry<java.lang.String,java.lang.Integer,T>
-
- com.opencsv.bean.PositionToBeanField<T>
-
- Type Parameters:
T
- Type of the bean being converted
- All Implemented Interfaces:
ComplexFieldMapEntry<java.lang.String,java.lang.Integer,T>
,java.lang.Iterable<FieldMapByPositionEntry<T>>
public class PositionToBeanField<T> extends AbstractFieldMapEntry<java.lang.String,java.lang.Integer,T> implements java.lang.Iterable<FieldMapByPositionEntry<T>>
Maps any column position matching a range definition to aBeanField
.- Author:
- Andrew Rucker Jones
-
-
Field Summary
-
Fields inherited from class com.opencsv.bean.AbstractFieldMapEntry
errorLocale, field
-
-
Constructor Summary
Constructors Constructor Description PositionToBeanField(java.lang.String rangeDefinition, int maxIndex, BeanField<T,java.lang.Integer> field, java.util.Locale errorLocale)
Initializes this mapping with a list of ranges and the associatedBeanField
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.boolean
contains(java.lang.Integer key)
Determines whether or not the given key is contained in this entry.java.lang.String
getInitializer()
Returns the information used to initialize this entry.java.util.Iterator<FieldMapByPositionEntry<T>>
iterator()
-
Methods inherited from class com.opencsv.bean.AbstractFieldMapEntry
getBeanField, setErrorLocale
-
-
-
-
Constructor Detail
-
PositionToBeanField
public PositionToBeanField(java.lang.String rangeDefinition, int maxIndex, BeanField<T,java.lang.Integer> field, java.util.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 Detail
-
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
public boolean contains(java.lang.Integer key)
Description copied from interface:ComplexFieldMapEntry
Determines whether or not the given key is contained in this entry.- Specified by:
contains
in interfaceComplexFieldMapEntry<java.lang.String,java.lang.Integer,T>
- Parameters:
key
- The key to be located- Returns:
- Whether
key
is represented by this entry
-
getInitializer
public java.lang.String 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<java.lang.String,java.lang.Integer,T>
- Returns:
- The original information used to initialize this mapping entry
-
iterator
public java.util.Iterator<FieldMapByPositionEntry<T>> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<T>
-
-