T
- The type of the bean being populatedI
- Type of the index into a multivalued fieldpublic class BeanFieldSplit<T,I> extends AbstractBeanField<T,I>
converter, errorLocale, field, fieldAccess, required, type
Constructor and Description |
---|
BeanFieldSplit(Class<?> type,
Field field,
boolean required,
Locale errorLocale,
CsvConverter converter,
String splitOn,
String writeDelimiter,
Class<? extends Collection> collectionType,
Class<?> elementType,
String capture,
String format)
The only valid constructor.
|
Modifier and Type | Method and Description |
---|---|
protected Object |
convert(String value)
This method manages the collection being created as well as splitting the
data.
|
protected String |
convertToWrite(Object value)
Manages converting a collection of values into a single string.
|
protected boolean |
isFieldEmptyForWrite(Object value)
Checks that
value is not null and not an empty
Collection . |
assignValueToField, getErrorLocale, getField, getFieldValue, getType, indexAndSplitMultivaluedField, isRequired, setErrorLocale, setField, setFieldValue, setRequired, setType, write
public BeanFieldSplit(Class<?> type, Field field, boolean required, Locale errorLocale, CsvConverter converter, String splitOn, String writeDelimiter, Class<? extends Collection> collectionType, Class<?> elementType, 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
- A Field
object.required
- Whether or not this field is required in inputerrorLocale
- The errorLocale to use for error messages.converter
- The converter to be used to perform the actual data
conversionsplitOn
- See CsvBindAndSplitByName.splitOn()
writeDelimiter
- See CsvBindAndSplitByName.writeDelimiter()
collectionType
- See CsvBindAndSplitByName.collectionType()
elementType
- See CsvBindAndSplitByName.elementType()
capture
- See CsvBindAndSplitByName.capture()
format
- The format string used for packaging values to be written.
If null
or empty, it is ignored.protected Object convert(String value) throws CsvDataTypeMismatchException, CsvConstraintViolationException
convert
in class AbstractBeanField<T,I>
value
- The string from the selected field of the CSV file. If the
field is marked as required in the annotation, this value is guaranteed
not to be null, empty or blank according to
StringUtils.isBlank(java.lang.CharSequence)
Object
representing the input data converted
into the proper typeCsvDataTypeMismatchException
- If the input string cannot be converted into
the proper typeCsvConstraintViolationException
- When the internal structure of
data would be violated by the data in the CSV fileConverterPrimitiveTypes.convertToRead(java.lang.String)
,
ConverterDate.convertToRead(java.lang.String)
,
ConverterNumber.convertToRead(String)
protected String convertToWrite(Object value) throws CsvDataTypeMismatchException
convertToWrite
in class AbstractBeanField<T,I>
value
- The contents of the field currently being processed from the
bean to be written. Can be null if the field is not marked as required.value
is nullCsvDataTypeMismatchException
- This implementation does not throw
this exceptionAbstractBeanField.write(java.lang.Object, java.lang.Object)
protected boolean isFieldEmptyForWrite(Object value)
value
is not null and not an empty
Collection
.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.